L2 Cache

Behold the power of |!

User Tools

Site Tools


configuration:xmonad

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
configuration:xmonad [2012/09/02 18:09]
sjorge [Packages]
configuration:xmonad [2014/10/09 22:02] (current)
Line 12: Line 12:
   * XMonad Contrib   * XMonad Contrib
   * Trayer   * Trayer
 +  * dmenu
   * dzen2   * dzen2
   * conky   * conky
Line 25: Line 26:
 | ~/​.xmonad/​.conky_dzen ​            | conky configuration for use with dzen             | | ~/​.xmonad/​.conky_dzen ​            | conky configuration for use with dzen             |
 | ~/​.xmonad/​dzen2/​* ​                | pixmap images used in my status bar               | | ~/​.xmonad/​dzen2/​* ​                | pixmap images used in my status bar               |
 +| ~/​.xmonad/​bin/​* ​                  | helper scripts and binries ​                       |
 | /​usr/​local/​bin/​xmonad-cdm-wrapper | wrapper for xmobad for use with cdm, tigervnc,​... | | /​usr/​local/​bin/​xmonad-cdm-wrapper | wrapper for xmobad for use with cdm, tigervnc,​... |
 +==== ~/​.xmonad/​xmonad.hs ====
 +<​code>​
 +-- ~/​.xmonad/​xmonad.hs
 +-- {{{ imports
 +-- generic
 +import XMonad
 +import XMonad.Util.Run
 +
 +-- actions
 +import XMonad.Actions.CycleWS
 +import XMonad.Actions.PerWorkspaceKeys
 +
 +-- hooks
 +import XMonad.Operations
 +import XMonad.Hooks.DynamicLog
 +import XMonad.Hooks.FadeInactive
 +import XMonad.Hooks.EwmhDesktops -- fix chromium fullscreen
 +import XMonad.Hooks.ManageDocks
 +import XMonad.Hooks.ManageHelpers
 +import XMonad.Hooks.SetWMName
 +
 +-- layout
 +import XMonad.Layout.NoBorders (smartBorders,​ noBorders)
 +import XMonad.Layout.PerWorkspace (onWorkspace,​ onWorkspaces)
 +import XMonad.Layout.SimpleFloat
 +import XMonad.Layout.ResizableTile
 +import XMonad.Layout.Grid
 +
 +-- misc
 +import System.Exit
 +import System.IO
 +import Data.Ratio ((%))
 +import qualified XMonad.StackSet as W
 +import qualified Data.Map as M
 +--}}}
 +
 +-- {{{ main
 +main = do
 +    dzenLeftBar <- spawnPipe myXmonadBar
 +    dzenRightBar <- spawnPipe myStatusBar
 +    xmonad $ ewmh defaultConfig { 
 +          terminal ​           = myTerminal
 +        , workspaces ​         = myWorkspaces
 +        , keys                = keys'
 +        , modMask ​            = modMask'​
 +        , layoutHook ​         = layoutHook'​
 +        , manageHook ​         = manageHook'​
 +        , logHook ​            = myLogHook dzenLeftBar >> fadeInactiveLogHook 0xdddddddd
 +        , normalBorderColor ​  = colorNormalBorder
 +        , focusedBorderColor ​ = colorFocusedBorder
 +        , borderWidth ​        = withPixelSize
 +  , startupHook  ​     = myStartup
 +    }
 +--}}}
 +
 +-- {{{ startup
 +myStartup :: X ()
 +myStartup = do
 +          spawn "​syndaemon -i 1 -t -d" -- synaptics timeout
 +          spawn "​trayer --edge top --align right --widthtype pixel --heighttype pixel --expand true --align right --SetDockType true --SetPartialStrut true --tint 0x000000 --transparent true --alpha 0 --margin 75 --height 8 --width 238"
 +          spawn "​xfce4-power-manager"​
 +          spawn "sleep 2; volti"
 +          spawn "sleep 2; wicd-gtk --tray"​
 +
 +--}}}
 +
 +-- {{{ config
 +-- terminal
 +myTerminal ​     = "​terminal"​
 +
 +-- modMask
 +modMask'​ :: KeyMask
 +modMask'​ = mod4Mask
 +
 +-- colors
 +colorNormalBorder ​  = "#​555753"​
 +colorFocusedBorder ​ = "#​8AE234"​
 +withPixelSize ​     = 1
 +
 +-- workspaces
 +myWorkspaces ​   = ["​1:​main","​2:​general","​3:​classic","​4:​vbox","​5:​web","​6:​irc"​]
 +
 +--}}}
 +
 +-- {{{ keys
 +keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList [
 +     ​((modMask,​  ​   xK_p ), bindOn [("​3:​classic",​ spawn "/​home/​sjorge/​.xmonad/​bin/​xmonad-xephyr-run"​),​ ("​4:​vbox",​ spawn "/​home/​sjorge/​.xmonad/​bin/​xmonad-windows-run"​),​ ("",​ spawn "​exe=`dmenu_run -nb black -sb black -nf \"#​555753\"​ -sf \"#​8AE234\"​` && eval \"exec $exe\""​)])
 +    , ((modMask .|. shiftMask, ​     xK_Return ​  ), spawn $ XMonad.terminal conf)
 +    , ((modMask, ​                   xK_F2       ), spawn "​gmrun"​)
 +    , ((modMask .|. shiftMask, ​     xK_c        ), kill)
 +    , ((modMask .|. shiftMask, ​     xK_l        ), spawn "​xlock"​)
 +
 +    -- Programs
 +    , ((0,                          xK_Print ​   ), spawn "scrot -e 'mkdie -p ~/​Documents/​screenshots/​ && mv $f ~/​Documents/​screenshots/'"​)
 +    , ((modMask .|. shiftMask, ​     xK_f        ), spawn "​firefox"​)
 +    , ((modMask .|. shiftMask, ​     xK_g        ), spawn "​thunar"​)
 +    , ((modMask .|. shiftMask, ​     xK_n        ), spawn "​wicd-gtk"​)
 +
 +    -- layouts
 +    , ((modMask, ​                   xK_space ​   ), sendMessage NextLayout)
 +    , ((modMask .|. shiftMask, ​     xK_space ​   ), setLayout $ XMonad.layoutHook conf)          -- reset layout on current desktop to default
 +    , ((modMask .|. shiftMask, ​     xK_m        ), windows W.shiftMaster) ​
 +    , ((modMask, ​                   xK_b        ), sendMessage ToggleStruts)
 +    , ((modMask, ​                   xK_F5       ), refresh)
 +    , ((modMask, ​                   xK_Tab ​     ), windows W.focusDown) ​
 +    , ((modMask .|. shiftMask, ​     xK_Tab ​     ), windows W.focusUp) ​
 +    , ((modMask, ​                   xK_j        ), sendMessage Expand) ​                         -- %! Shrink a master area
 +    , ((modMask .|. shiftMask, ​     xK_j        ), sendMessage Shrink) ​                         -- %! Expand a master area
 +    , ((modMask, ​                   xK_e        ), sendMessage (IncMasterN 1))
 +    , ((modMask, ​                   xK_r        ), sendMessage (IncMasterN (-1)))
 +
 +    -- workspaces
 +    , ((modMask .|. controlMask, ​  ​xK_Right ​    ), nextWS)
 +    , ((modMask .|. shiftMask, ​    ​xK_Right ​    ), shiftToNext)
 +    , ((modMask .|. controlMask, ​  ​xK_Left ​     ), prevWS)
 +    , ((modMask .|. shiftMask, ​    ​xK_Left ​     ), shiftToPrev)
 +    ​
 +    -- quit, or restart
 +    , ((modMask .|. shiftMask, ​     xK_q        ), io (exitWith ExitSuccess))
 +    , ((modMask, ​                   xK_q        ), spawn "​killall conky dzen2 trayer syndaemon ; wicd-tray-kill ; xmonad --recompile && xmonad --restart"​)
 + ]
 +--}}}
 +
 +-- {{{ statusbar
 +myBitmapsDir = "/​home/​sjorge/​.xmonad/​dzen2"​
 +
 +-- dzen2 1366 - 1024 = 342
 +myXmonadBar = "dzen2 -w 1054 -h 16 -ta '​l'​ -fg '#​555753'​ -bg '#​000000'​ -fn '​Terminus-8'"​
 +myLogHook :: Handle -> X ()
 +myLogHook h = dynamicLogWithPP $ defaultPP
 +    {
 +        ppCurrent ​          ​= ​  ​dzenColor "#​8AE234"​ "#​000000"​ . pad
 +      , ppVisible ​          ​= ​  ​dzenColor "#​555753"​ "#​000000"​ . pad
 +      , ppHidden ​           =   ​dzenColor "#​999999"​ "#​000000"​ . pad
 +      , ppHiddenNoWindows ​  ​= ​  ​dzenColor "#​555753"​ "#​000000"​ . pad
 +      , ppUrgent ​           =   ​dzenColor "#​cc0000"​ "#​000000"​ . pad
 +      , ppWsSep ​            ​= ​  ""​
 +      , ppSep               ​= ​  "​ | "
 +      , ppLayout ​           =   ​dzenColor "#​555753"​ "#​000000"​ .
 +                                (\x -> case x of
 +                                    "​ResizableTall" ​            ​-> ​     "​^i("​ ++ myBitmapsDir ++ "/​tall.xbm)"​
 +                                    "​Mirror ResizableTall" ​     ->      "​^i("​ ++ myBitmapsDir ++ "/​mtall.xbm)"​
 +                                    "​Full" ​                     ->      "​^i("​ ++ myBitmapsDir ++ "/​full.xbm)"​
 +                                    "​Simple Float" ​             ->      "​~"​
 +                                    "IM Grid" ​                  ​-> ​     "​IM"​
 +                                    _                           ​-> ​     x
 +                                )
 +      , ppTitle ​            ​= ​  ​(""​ ++) . dzenColor "#​B9EE85"​ "#​000000"​ . dzenEscape
 +      , ppOutput ​           =   ​hPutStrLn h
 +    }
 +
 +-- conky
 +myStatusBar = "conky -c /​home/​sjorge/​.xmonad/​.conky_dzen_clock | dzen2 -x 1291 -w 75 -h 16 -ta '​r'​ -fg '#​555753'​ -bg '#​000000'​ -fn '​Terminus-8'"​
 +
 +--}}}
 +
 +-- {{{ hooks
 +-- management
 +manageHook'​ :: ManageHook
 +manageHook'​ = (composeAll . concat $
 +    [ [resource ​    =? r            --> doIgnore ​            ​| ​  ​r ​  <- myIgnores ​  ] -- ignore desktop
 +    , [className ​   =? c            --> doShift ​ "​1:​main" ​   |   ​c ​  <- myMain ​     ] -- move dev to main
 +    , [className ​   =? c            --> doShift ​ "​2:​general"​ |   ​c ​  <- myGeneral ​  ] -- move general to general
 +    , [name         =? n            --> doShift ​ "​3:​classic"​ |   ​n ​  <- myClassic ​  ] -- move general to general
 +    , [name         =? n            --> doShift ​ "​4:​vbox" ​   |   ​n ​  <- myVbox ​     ] -- move general to general
 +    , [className ​   =? c            --> doShift ​ "​5:​web" ​    ​| ​  ​c ​  <- myWebs ​     ] -- move webs to web
 +    , [className ​   =? c            --> doShift "​6:​irc" ​    ​| ​  ​c ​  <- myIRC       ] -- move irc to irc  ​
 +    , [className ​   =? c            --> unfloat ​             |   ​c ​  <- myNoFloatsC ] -- unfloat my floats
 +    , [className ​   =? c            --> doCenterFloat ​       |   ​c ​  <- myFloatsC ​  ] -- float my floats
 +    , [name         =? n            --> doCenterFloat ​       |   ​n ​  <- myFloatsN ​  ] -- float my names
 +    , [isFullscreen ​                ​-->​ myDoFullFloat ​                              ]
 +    , [manageDocks  ​   ]
 +    ]) 
 + 
 +    where
 +        role      = stringProperty "​WM_WINDOW_ROLE"​
 +        name      = stringProperty "​WM_NAME"​
 +        unfloat = ask >>= doF . W.sink
 +
 +        -- sorters
 +        myMain  ​ = ["​Terminal"​]
 +        myGeneral = ["​Thunar",​ "​Deluge","​Ristretto"​]
 +        myClassic = ["​Xmonad Classic"​]
 +        myVbox  ​ = ["​VirtualBox - Windows 7"]
 +        myWebs ​   = ["​Firefox","​Google-chrome","​Chromium","​Chromium-browser","​Opera"​]
 +        myIRC  ​ = ["​Xchat"​]
 +
 +        -- resources
 +        myIgnores = ["​desktop","​desktop_window","​notify-osd","​stalonetray","​trayer"​]
 + 
 +        -- floats
 +        myFloatsC ​ = ["​VirtualBox","​Xmessage","​XFontSel","​Downloads","​Wicd-client.py","​xfce4-power-information","​xfce4-power-manager-settings"​]
 +        myFloatsN ​ = ["​Google Chrome Options","​Chromium Options","​XChat:​ Network List"]
 +        myNoFloatsC = ["​Xephyr",​ "​VirtualBox"​]
 +
 +-- fullscreen with focus 
 +myDoFullFloat :: ManageHook
 +myDoFullFloat = doF W.focusDown <+> doFullFloat
 +
 +-- layouts
 +layoutHook' ​ =  onWorkspaces ["​1:​main" ​   ] customLayoutTilted $
 +                onWorkspaces ["​3:​classic"​ ] customLayoutFull $
 +                onWorkspaces ["​4:​vbox"​ ] customLayoutFull $
 +                onWorkspaces ["​5:​web" ​    ] customLayoutFull $
 +                onWorkspaces ["​6:​irc" ​    ] customLayoutFull $
 +                customLayoutDefault
 +
 +customLayoutTilted = avoidStruts $ tiled ||| Mirror tiled
 + where
 +    tiled ​  = ResizableTall 1 (2/100) (1/2) []
 +
 +customLayoutDefault = avoidStruts $ Full ||| tiled ||| Mirror tiled
 + where
 + tiled ​  = ResizableTall 1 (2/100) (1/2) []
 +
 +customLayoutFull = avoidStruts $ smartBorders Full 
 +--customLayoutFloat = avoidStruts $ simpleFloat
 +
 +--}}}
 +</​code>​
 +==== ~/​.xmonad/​apps ====
 +<​code>​
 +#!/bin/bash
 +## core x configuration
 +xsetroot -solid black
 +xloadimage -onroot -center /​home/​sjorge/​Documents/​Themes/​Backgrounds/​xmonad.png
 +xsetroot -cursor_name left_ptr
 +setxkbmap -layout be
 +xbindkeys
 +
 +## default apps
 +sleep 5
 +#xchat &
 +chromium &
 +</​code>​
 +==== ~/​.xmonad/​.conky_dzen ==== 
 +<​code>​
 +background yes
 +out_to_console yes
 +out_to_x no
 +# Update interval in seconds
 +update_interval 3
 +
 +TEXT
 +${if_empty ${exec ifconfig wlan0 | grep 'inet '​}}^i(/​home/​sjorge/​.xmonad/​dzen2/​net-wired.xbm)${else}^i(/​home/​sjorge/​.xmonad/​dzen2/​wifi_01.xbm) ${exec iwconfig wlan0 | grep '​Signal level' | cut -d= -f3 | awk '​{print 100+$1 "​%"​}'​} ${exec iwgetid | cut -d\" -f2 | awk '​{print ​ $1}'​}${endif} ${if_match ${exec cat /​sys/​class/​power_supply/​ADP1/​online} == 1}^i(/​home/​sjorge/​.xmonad/​dzen2/​ac_01.xbm)${else}^i(/​home/​sjorge/​.xmonad/​dzen2/​bat_full_01.xbm)${endif} ${battery_percent BAT0}% | ^fg(\#​B9EE85)${time %a %H:%M}
 +</​code>​
  
 +**note: use sed or simular to replace my username** ''​sed '​s/​sjorge/​**YOURUSER**/​gi'​ tempfile > .conky_dzen''​
 ==== /​usr/​local/​bin/​xmonad-cdm-wrapper ====  ==== /​usr/​local/​bin/​xmonad-cdm-wrapper ==== 
 <​code>​ <​code>​
Line 32: Line 281:
 ## apps ## apps
 [ -e ~/​.xmonad/​apps ] && ~/​.xmonad/​apps & [ -e ~/​.xmonad/​apps ] && ~/​.xmonad/​apps &
- 
 ## xmonad ## xmonad
 exec ck-launch-session dbus-launch xmonad exec ck-launch-session dbus-launch xmonad
 </​code>​ </​code>​
 +
 +==== ~/​.xmonad/​bin/​xmonad-windows-run ==== 
 +<​code>​
 +#!/bin/sh
 +
 +if [ "​$(VBoxManage list runningvms | grep -ci hikari)"​ -lt 1 ]; then
 + exec Xephyr -screen 1366x752 -terminate -title "​VirtualBox - Windows 7" :4 &
 + xdotool search --classname "​Xephyr"​ windowmove 0 16
 + xdotool search --classname "​Xephyr"​ windowsize 1366 752
 + DISPLAY=:4 exec VirtualBox --startvm Hikari &
 +fi
 +</​code>​
 +
 +==== ~/​.xmonad/​bin/​xmonad-xephyr-run ==== 
 +<​code>​
 +#!/bin/sh
 +
 +if [ "$(ps aux | grep Xephyr | grep -v grep | grep -vi virtualbox | wc -l)" -lt 1 ]; then
 + exec Xephyr -screen 1366x752 -terminate -title "​Xmonad Classic"​ :3 &
 + xdotool search --classname "​Xephyr"​ windowmove 0 16
 + xdotool search --classname "​Xephyr"​ windowsize 1366 752
 + sleep 1
 + export DISPLAY=:3
 + exec xfce4-session
 + sleep 1
 + exe=`dmenu_run_xephyr -nb black -sb black -nf "#​555753"​ -sf "#​8AE234"​`
 + eval "exec $exe"
 +else
 + export DISPLAY=:3
 + exe=`dmenu_run_xephyr -nb black -sb black -nf "#​555753"​ -sf "#​8AE234"​`
 + eval "exec $exe"
 +
 +fi
 +</​code>​
 +
 +==== ~/​.xmonad/​bin/​xmonad-xephyr-kill ==== 
 +<​code>​
 +#!/bin/sh
 +
 +PID=$(ps aux | grep Xephyr | grep :3 | grep -v grep | awk '{ print $2 }')
 +
 +if [ ! -z $PID ]; then
 + kill $PID
 +fi
 +</​code>​
 +==== ~/​.xmonad/​dzen2/​ ==== 
 +{{:​configuration:​dzen2.tar|}}
 +
 +<​konsole>​
 +yami ~# mkdir -p ~/.xmonad
 +yami ~# tar xvf dzen2.tar -C ~/.xmonad
 +</​konsole>​
 +
configuration/xmonad.1346602142.txt.gz · Last modified: 2014/10/09 22:02 (external edit)