Toggling Xfce4-panel via keypress

(Maybe this should be in section Contributions, not sure)

There’s another topic about this, but it was already locked, so I couldn’t add this info.

I made a little script to toggle hiding/unhiding the xfce panel. I found the code here that I modified for this use case, but I guess it could be modified for any possible use case.

So here is the bash script (saved as togglepanel.sh):

current_panelsetting=$(xfconf-query -c xfce4-panel -p /panels/panel-0/autohide-behavior)


if [[ $current_panelsetting == 0 ]]; then
    xfconf-query -c xfce4-panel -p /panels/panel-0/autohide-behavior -t uint -s 2
else 
    xfconf-query -c xfce4-panel -p /panels/panel-0/autohide-behavior -t uint -s 0
fi

Then in Keyboard settings tab Application shortcuts, you click add, click on the file browse icon and select the bash script, then press the preferred shortcut key.

Maybe it’s even possible to toggle between all 3 settings by modifying the script and add an ifelse command or something.

Edit: I just noticed that I’m posting in the Manjaro xfce forum, while I forgot I just switched to Mint xfce for the moment (no good reason). I just tested via a live-usb boot and it works there as well.
The only difference is that the first panel in Mint is panel-1, while in Manjaro it’s panel-0. I already modified the above code block so it’s correct for Manjaro xfce.

A post was merged into an existing topic: Command for toggling Xfce4-panel