2

My laptop is running Linux Mint 17 XFCE Edition, and I'm trying to set it up so that I can use Emacs with my usual keybindings. These include certain autocompletion/fill commands involving Alt-Tab, and at present the OS's Alt-Tab and Shift-Alt-Tab application switcher intercepts any commands I try to use including these keys.

I would like to be able to run some kind of monitor script that detects when Emacs is running (or focused, even), disables both Alt-Tab and Shift-Alt-Tab shortcuts, and then resets them once emacs is no longer running.


My Attempted Solution: Based on a wonderful answer I received over at AskUbuntu to a related question using gsettings, I thought I'd try the following:

#!/bin/bash

disabled="0" # Track whether or not <Alt>Tab and <Alt><Shift>Tab are currently disabled

while true; do
    isActive=$(wmctrl -lx | awk -v search=$(printf 0x0%x $(xdotool getactivewindow)) -v wm_class="$wm_class" '{ if($1 ~ search && $3 ~ /emacs/) print $3 }')

    if [[ "$isActive" != "" ]]; then
        # echo "active"
        if [[ "$disabled" == "0" ]]; then
            # echo "disable shortcuts"
            xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Alt>Tab" -s ""
            xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Alt><Shift>Tab" -s ""
            disabled="1"
        fi
    else
        # echo "not active"
        if [[ "$disabled" == "1" ]]; then
            # echo "enable shortcuts"
            xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Alt>Tab" -r
            xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Alt><Shift>Tab" -r
            disabled="0"
        fi
    fi
    sleep 1

done

While this does seem to set/reset the relevant keybinding settings, these settings won't take effect until I log out and log back in, which sort of defeats the purpose of this script. Is there some other command I need to run in order to get XFCE to process its keybinding settings after making changes? Should I not be setting the keybindings to empty strings to disable them? Or is there something else I'm missing here?

I'm hoping/assuming there's a way to do this without having to log out/log back in, since that would definitely be more trouble than it's worth here.

Thanks in advance for any help you can provide!

1

If those settings are not applied, than your desktop is broken.

Is xfsettingsd running and reacting? Is xfwm4 running and reacting?

Join me in IRC for live help

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.