Skip to content

Instantly share code, notes, and snippets.

@c33k
Last active November 2, 2023 14:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save c33k/1ecde9be24959f1c738d to your computer and use it in GitHub Desktop.
Save c33k/1ecde9be24959f1c738d to your computer and use it in GitHub Desktop.
Xmonad default shortcuts and a simple tutorial on how to change it adding volume controll shortcuts.

A list of xmonad default keyboard shortcuts.

alt+shift+ENTER: opens terminal
alt+SPACE: change layout
alt+K, alt+J: change window focus
alt+H, alt+L: decreases/increases border size between windows
alt+shift+C: close focused window
alt+ENTER: move focused window to the master pane on the left
alt+shift+Q: log out
alt+Q: reload xmonad configurations

If you're using suckless-tools, alt+p shows a bar where you can load whichever program is installed.

###Installation on Ubuntu

sudo apt-get install xmonad suckless-tools

To load it, choose xmonad as your window manager on your XDM or GDM login screen.

###Change keyboard layout using `setxkbmap

In this example, I'm using an abnt2 keyboard - "português BR"

$setxkbmap -model abnt2 -layout br

###Change backgroung image using xloadimage

xloadimage -onroot -fullscreen <image-path>

###Adding volume keys
To add volume controlls on keyboard, we need to install xmonad-extras from Hackage running the following commands:

sudo apt-get install cabal-install
sudo cabal update
sudo cabal install xmonad-extras

cabal-install automates Haskell libraries installation, managing it`s dependencies.

To change xmonad configurations, we need to create the ~/.xmonad/xmonad.hs file and add our custom configurations in it.
For a basic configuration template, see this link.

Now, to set the volume keys, we can follow dmwits' steps summarized bellow:

import XMonad
import XMonad.Actions.Volume
import Data.Map    (fromList)
import Data.Monoid (mappend)

main = xmonad defaultConfig { keys =
    keys defaultConfig `mappend`
    \c -> fromList [
        ((0, xK_F6), lowerVolume 4 >> return ()),
        ((0, xK_F7), raiseVolume 4 >> return ())
    ]
}

The code above configures F6 and F7 keys to lower and raise volume by 4 units.

###Running scripts on start up (Ubuntu Gnome) If you want to add some scripts (like that I used to set background and keyboard layout), you can run gnome-session-properties and add it there. Those scripts will run whenever a user logs in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment