Code:
#!/bin/bash
# read xresource colors to array "xrdb"
xrdb=( $(xrdb -query | grep -P "color[0-9]*:" | sort | cut -f 2-) )
# `sort` doesn't quite sort ascending, it sorts "0, 10, 11, 12, ..., 1, 2, 3, ...", so we need to fix.
# while we're at it, we might as well use proper names.
# define array "color" (actually a hash table)
declare -A color
# need this to get the values from xrdb one by one
index=0
# loop over color names
for name in black brightgreen brightyellow brightblue brightmagenta brightcyan brightwhite red green yellow blue magenta cyan white grey brightred; do
# assign color value from array xrdb to hash "color"
color[${name}]=${xrdb[$index]}
# increase "index" by one, so we get the next color value for the next iteration
((index++))
done
# Just some display demo from here on...
for name in black brightgreen brightyellow brightblue brightmagenta brightcyan brightwhite red green yellow blue magenta cyan white grey brightred; do
echo -n "^bg(${color[${name}]}) "
done
echo -n "^bg()"
echo -n "^fg(${color['black']}) black "
echo -n "^fg(${color['red']}) red "
echo -n "^fg(${color['green']}) green "
echo -n "^fg(${color['yellow']}) yellow "
echo -n "^fg(${color['blue']}) blue "
echo -n "^fg(${color['magenta']}) magenta "
echo -n "^fg(${color['cyan']}) cyan "
echo -n "^fg(${color['white']}) white "
echo -n "^fg(${color['grey']}) grey "
echo -n "^fg(${color['brightred']}) brightred "
echo -n "^fg(${color['brightgreen']}) brightgreen "
echo -n "^fg(${color['brightyellow']}) brightyellow "
echo -n "^fg(${color['brightblue']}) brightblue "
echo -n "^fg(${color['brightmagenta']}) brightmagenta "
echo -n "^fg(${color['brightcyan']}) brightcyan "
echo -n "^fg(${color['brightwhite']}) brightwhite "
echo
Code:
import XMonad
import Control.Monad
import XMonad.Util.EZConfig
import XMonad.Util.Run(spawnPipe)
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Layout.Spacing
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import System.IO
myWorkspaces = ["main", "test", "music", "web", "other"]
myStatusBar = "sh ~/scripts/barcolor.sh | dzen2 -p -fn 'lime-10'"
main = do
dzenTopBar <- spawnPipe myStatusBar
xmonad $ defaultConfig
{ manageHook = manageDocks <+> manageHook defaultConfig
, borderWidth = 3
, terminal = "urxvt"
, normalBorderColor = "#7c7c7c"
, focusedBorderColor = "#0088cc"
, workspaces = myWorkspaces
, modMask = mod4Mask
, layoutHook = avoidStruts $ spacing 3 $ Tall 1 (3/100) (1/2)
} `additionalKeys` myKeys
myKeys =
[ ((mod4Mask .|. shiftMask, xK_r), spawn "dmenu_run -b")
, ((controlMask, xK_Print), spawn "scrot -cd 1")
, ((0, xK_Print), spawn "scrot")
, ((mod4Mask .|. shiftMask, xK_c), spawn "chromium")
, ((mod4Mask .|. shiftMask, xK_x), kill)
]