Toggle the Visibility of the Cinnamon Panel

Libervurto
  8 years ago
  -1

This is my first Linux tutorial (and one of my first bash scripts!) so I thought I'd keep it simple.

I like to autohide my Cinnamon panel to free up screen space and help me focus on the active application window.  (I also use maximus to hide window titlebars.)  However, I prefer to use the mouse as little as possible, so having to move the mouse cursor to the top of the screen every time I want to check the time—or I forget which applications I have open!—is a real pain.

To solve this problem I wrote a simple little script to toggle the value of the /org/cinnamon/panel-autohide flag, which as you might guess sets whether the panel will autohide or remain at the top of the screen.

To use this script you must have dconf-cli installed on your system (I'm pretty sure it should be by default).

#!/bin/bash
 
# get state of panel-autohide
state=`dconf read /org/cinnamon/panel-autohide`
 
# if autohide on, turn it off and vice versa
if [ $state = "true" ]; then
    dconf write /org/cinnamon/panel-autohide false
else
    dconf write /org/cinnamon/panel-autohide true
fi
#!/bin/bash
 
# get state of panel-autohide
state=`dconf read /org/cinnamon/panel-autohide`
 
# if autohide on, turn it off and vice versa
if [ $state = "true" ]; then
    dconf write /org/cinnamon/panel-autohide false
else
    dconf write /org/cinnamon/panel-autohide true
fi
#!/bin/bash
 
# get state of panel-autohide
state=`dconf read /org/cinnamon/panel-autohide`
 
# if autohide on, turn it off and vice versa
if [ $state = "true" ]; then
    dconf write /org/cinnamon/panel-autohide false
else
    dconf write /org/cinnamon/panel-autohide true
fi
 
#!/bin/bash
 
# get state of panel-autohide
state=`dconf read /org/cinnamon/panel-autohide`
 
# if autohide on, turn it off and vice versa
if [ $state = "true" ]; then
    dconf write /org/cinnamon/panel-autohide false
else
    dconf write /org/cinnamon/panel-autohide true
fi
 
Save this script to a file somewhere in your home folder.  I recommend creating a new folder for all your scripts and giving it a short name like ~/.src/ as you will often need to type it.  Then all you need to do is bind a key to it.  If you don't know how to bind keys and your desktop environment doesn't have a built-in keyboard shortcuts menu then search for xbindkeys; it's a very easy program to use.
 
Sorry I do not know how to properly format source code on here. blush
Comments
Rebel450 8 years ago

@remoulder .... ts, ts, ts


MagicMint 8 years ago

By storing your scripts in ~/bin, you wouldn’t need to enter the path because that’s the standard location in Debian-Ubuntu-Mint for executables in a user’s home directory.

The tutorial strictly refers to Cinnamon, hence there is always a built-in keyboard shortcut facility ;-)


MagicMint 8 years ago

@remoulder: What has the tutorial above to do with actions ? It just explains how to display the panel in Cinnamon by just a keypress.


remoulder 8 years ago

A tutorial explains how to perform an action, please use the forums to discuss scripting