I started using emacs for programming and for LaTeX and I would like to have it's basic commands on my background so I can easily just "show my desktop" using a shortcut... taking a look to my background to see the commands and returning to my emacs window to continue the work. I think it will be a useful customization for many users that like programming and especially for users that are not already used to emacs commands.

The best I could imagine is to have some basic commands on my desktop image and some shortcut keys to change the image to some more specific (for C++ language, for latex etc.)

I can create images using latex and the original background of my OS.

My question is if and how I can make these images to display as background by just pressing Ctrl+Alt+H or something similar.

  • This sounds like you have not yet discovered the self-documenting facilities in Emacs. Intermediate Emacs users primarly rely on Emacs itself for reminding them of command names and available facilities. Probably now would be a good time to take the built-in tutorial (C-h t). – tripleee Jul 15 '17 at 6:47
  • @tripleee all the notes of my image file are from this tutorial. But I like them in less words as a list to learn them the easy way. – koleygr Jul 15 '17 at 7:17
  1. We can find our used images in /usr/share/desktop-base/softwaves-theme/wallpaper/contents/images (It's the default images I think).

    cd /usr/share/desktop-base/softwaves-theme/wallpaper/contents/images

    we can find which image we are using by command:

    gsettings get org.gnome.desktop.background picture-uri

  2. We copy the one we need (or all if we don't know which to use) in a folder: Let's say in ~/bg_images/.

    mkdir ~/bg_images/

    cp *.* ~/bg_images/

    cd ~/bg_images

  3. We open the image we are going to use with GIMP and exporting as png.

    Gimp->export as->select png files->set compression to 0->enter

Let's say it was the image 1280x720.svg and we created 1280x720.png.

  1. We open a file image1.tex (in the same folder) and add the code:

           \node at (0,0) {\includegraphics{1280x720.png}};
           \node at (1.2,0) {
                 {\Huge \bfseries emacs controls:}
         \noindent{\Large\bfseries Navigation}\vspace{5pt}
         \begin{tabular}{>{\bfseries}r l}
            C-v:& Goes to next page.\\
            M-v:& Goes to previous page.\\
            C-l:& Moves the screen around the cursor's line.\\ 
            &(once $->$ center,\\ 
            &twice $->$ top,\\ 
            &three times $->$ bottom).\\
            C-n:& Next line.\\
            C-p:& Previous line.\\
            C-b:& Previous character (Backward).\\
            C-f:& Next character (Forward).\\
            C-a:& Beginning of line.\\
            C-e:& End of line.\\
            M-f:& Forward a word.\\
            M-b:& Backward a word.\\
            M-a:& Back to beginning of sentence.\\
            M-e:& Forward to end of sentence.\\
            M-\blg:& Move to End of file.\\
            M-\bll:& Move to Beginning of file.\\
         \noindent{\Large\bfseries Numerical arguments in commands}\vspace{5pt}
         \begin{tabular}{>{\bfseries}l l}
            C-u \bll Num\blg \bll command\blg :& Repeats $<$comand$>$ \\
            &Num times.\\ 
            Exceptions: & {\bfseries C-v} and {\bfseries M-v}\\
            & scrolls Num lines.\\
         \noindent{\Large\bfseries Cancel non-responding or incomplete command}\vspace{5pt}
            {\bfseries C-g}\\
         \noindent{\Large\bfseries Change buffer etc}\vspace{5pt}
            C-x b: & Select buffer \\
            & Default [Enter]\\
            & [tab] show possible.\\
            C-x 1: & kill all buffers\\
            & but cursor's current.\\
            & [it is digit one]\\
            C-x 2:& Splits current window in two.\\
            C-x o:& moves cursor to other window.\\
            C-M-v:& Scrolls other window.
         \noindent{\Large\bfseries Mark from}\vspace{5pt}
            C-\bll SPC\blg\\
         \noindent{\Large\bfseries Delete and kill}\vspace{5pt}
         \begin{tabular}{>{\bfseries}r l}
         \bll DEL\blg & Delete char just before cursor.\\
         C-d: & Delete char just after cursor.\\
         M-\bll DEL\blg: & Kill word just before cursor.\\
         M-d: & Kill word just after cursor.\\
         C-k: & Kill from cursor to end of line.\\
         M-k: & Kill from cursor to end of sentence.\\
         C-w: & Kill from mark point to cursor.
         \noindent{\Large\bfseries Restore killed text ``Yanking''}\vspace{5pt}
         \begin{tabular}{>{\bfseries}l l}
            C-y: & Restore last killed or last row killed text.\\
            M-y: & Restore previous killed text.
         \noindent{\Large\bfseries Undo}\vspace{5pt}
            C-x u\\
         \noindent{\Large\bfseries Files \& Buffers}\vspace{5pt}
            C-x C-f: & Find a file.\\
            C-x C-s: & Save active file.\\
            C-x C-b: & List buffers.\\
            C-x b \bll BufferName\blg:& Visit buffer.\\
            C-x s: & Save some buffers.\\
            C-x C-c:& Exit emacs.\\
            C-z:& Suspend emacs\\
            & return with \%emacs or 'fg'\\
         \noindent{\Large\bfseries Search}\vspace{5pt}
            C-s:& Forward search \\
            & (repeat C-s for next)\\
            C-r:& Backward search\\
            & Both navigate back and forth.
         \noindent{\Large\bfseries More Useful Commands}\vspace{5pt}
         \begin{tabular}{>{\bfseries}r l}
            M-x replace-string:& Replace string after cursor.\\
            &(First letters and TAB \\
            & are enough to show it.)\\
            M-x recover-file: & Restores file.\\
            M-x auto-fill-mode: & Automatic breaks lines.\\
            M-x text-mode: & Human text.\\
            C-x f \bll NumChars\blg : & Chars in line.\\
            M-q: &Fix chars in paragraph.\\
            C-u 70 C-x f: & 70 chars per line.\\
            C-h c \bll comand\blg:& Basic help on command.\\
            C-h k \bll command \blg:& Extended help on command.\\
            C-h f \bll function \blg:& Help about function.\\
            C-x i:& Read included manuals.
  2. We compile with pdflatex image1.tex and we get the file image1.pdf.

    pdflatex image1.tex

  3. Then we have an image1.pdf file and we convert it to svg with texlive convert command:

    convert image1.pdf image1.svg

We can avoid the next steps until step 13 by just using the code in the script in our shortcut command creation

  1. We create a directory 'bin' in our home folder (if we don't already have one)

    mkdir ~/bin

    cd ~/bin

  2. We open a file 'change_background.sh'

    nano change_background.sh

  3. We copy paste the code:



    if [ "x$file_path" != "x" ];

    then gsettings set org.gnome.desktop.background picture-uri file://"$file_path" fi

  4. Save and close

  5. chmod +x change_background.sh

  6. Then we open settings from the top right corner:

    All Settings->keyboard->scroll down to bottom->press '+'

  7. We create a custom shortcut (Let's say it show_emacs_help) with the command

    bash /home/userName/bin/change_background.sh /home/userName/bg_images/image1.svg

    where "userName" is our username

  8. We chose our shortcut keys (Lets say Ctrl+Alt+H)

  9. We can add in the same way a new shortcut to reload the default backgroound image.

PS: Source for the script: https://askubuntu.com/questions/858663/how-to-change-background-with-keyboard-shortcut Selected answer by @SergiyKolodyazhnyy.

Result image:

enter image description here

  • The change-background.sh script is of very marginal usefulness compared to the number of complications it adds to this exposition. Maybe trust users to figure out how to script it if they are really ever going to need it more than once? – tripleee Jul 15 '17 at 6:54
  • And if you do script things, you could replace the GUI right-click this and that with a one-liner to paste in a terminal window. – tripleee Jul 15 '17 at 6:56
  • Thank you for your comment ... May be I will edit the answer to do it simpler. Thanks again! – koleygr Jul 15 '17 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.