1

Emacs newbie here. I simply want to setup Emacs GUI to toggle hide/show(visibility) just like we see in guake, tilda or yakuake terminals. for example I have am working with Emacs within GUI and I have a browser window behind it, I want to hide Emacs with a shortcut(e.g F12) and then I will see my browser and will be able to interact with it and other windows, then again press F12 and I will have my Emacs GUI back. If it is not possible from inside Emacs, can I do this from desktop(running KDE 5.13).

  • 1
    Please explain in more detail what "toggle hide/show(visibility)" means for people that do not know guake, tilda, or yakuake. Note that C-z is bound to the command suspend-frame which hides the active emacs frame. – Tobias Aug 14 '18 at 7:40
  • @Tobias thanks for your comment. I updated the question to better explain the question. – milad zahedi Aug 14 '18 at 8:12
  • 1
    Please try C-z, i.e., hold the control key down and press the z-key. The emacs frame will be hidden. Pressing C-z again reveals the emacs frame again. Is that what you want? Note, I've tested that under Windows10/cygwin. Don't know wether it works under X11/KDE. It should work. – Tobias Aug 14 '18 at 8:27
  • 1
    You wrote in your comment: "I don't think that you will be able to interact with the browser after C-z. I want the GUI to go completely away and let me interact with other windows". But you wrote in your question: "I want to hide Emacs with a shortcut(e.g F12) and then I will see my browser, then again press F12 and I will see my Emacs GUI". C-z does exactly what you wrote in your question (at least under Win10/cygwin) but not what you wrote in your comment. I think you should update your question with the relevant text from your comment. – Tobias Aug 14 '18 at 9:49
  • 2
    I really do think it's more of a window manager question... – manandearth Aug 14 '18 at 20:09
1

I use this script (I found it, it is in Russian):

#!/bin/bash
######################################################################################################
# This script will toggle minimize/activate first window with specified class
# If window not found program will be launched
#
# window class can be found with next programs:
#   wmctrl -x -l
#   xprop
# No credit taken.......... Cannot read the original.....
# Found on http://blog.sokolov.me/2014/06/20/linuxx11-toggle-window-minimizemaximize/
# in Russian :) but works when adjusting the wrapping.
######################################################################################################
NEEDED_WINDOW_CLASS="emacs.Emacs"
LAUNCH_PROGRAM="emacs"
######################################################################################################
NEEDED_WINDOW_WINDOW_ID_HEX=`wmctrl -x -l | grep ${NEEDED_WINDOW_CLASS} | awk '{print $1}' | head -n 1`
NEEDED_WINDOW_WINDOW_ID_DEC=$((${NEEDED_WINDOW_WINDOW_ID_HEX}))
if [ -z "${NEEDED_WINDOW_WINDOW_ID_HEX}" ]; then
${LAUNCH_PROGRAM}
else
echo "Found window ID:${NEEDED_WINDOW_WINDOW_ID_DEC}(0x${NEEDED_WINDOW_WINDOW_ID_HEX})"
ACIVE_WINDOW_DEC=`xdotool getactivewindow`
if [ "${ACIVE_WINDOW_DEC}" == "${NEEDED_WINDOW_WINDOW_ID_DEC}" ]; then
    xdotool windowminimize ${NEEDED_WINDOW_WINDOW_ID_DEC}
else
    xdotool windowactivate ${NEEDED_WINDOW_WINDOW_ID_DEC}
    fi
fi

Assign the script to a hotkey.

  • and how can I assign the script to a hotkey ? – milad zahedi Aug 26 '18 at 8:45
  • I confirm that this works after install xdotool and wmctrl – milad zahedi Aug 26 '18 at 9:09

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.