public
Created

Herbstluftwm config

  • Download Gist
autostart
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
#!/bin/bash
xrdb /home/polo/.Xresources
 
 
# this is a simple config for herbstluftwm
 
function hc() {
herbstclient "$@"
}
 
hc emit_hook reload
 
xsetroot -solid '#5A8E3A'
 
# modules
## colors
hfsdir="$HOME/.config/herbstluftwm/scripts"
source "$hfsdir/colors.sh";
 
# remove all existing keybindings
hc keyunbind --all
 
 
#################
## keybindings ##
#################
 
Mod=Mod4
 
# herbstluftwm
hc keybind $Mod-Shift-q quit
#hc keybind $Mod-Control-r reload
hc keybind $Mod-Shift-c close
 
# volume
hc keybind XF86AudioRaiseVolume spawn amixer set Master 3%+ unmute
hc keybind XF86AudioLowerVolume spawn amixer set Master 3%- unmute
hc keybind Shift-XF86AudioRaiseVolume spawn amixer set Master 1%+ unmute
hc keybind Shift-XF86AudioLowerVolume spawn amixer set Master 1%- unmute
hc keybind XF86AudioMute spawn amixer set Master toggle
 
# mpd
hc keybind XF86AudioPlay spawn mpc toggle
hc keybind XF86AudioPrev spawn mpc prev
hc keybind XF86AudioNext spawn mpc next
 
# applications
hc keybind $Mod-Return spawn dmenu_run
hc keybind $Mod-i spawn urxvt
hc keybind XF86HomePage spawn dwb
hc keybind $Mod-XF86AudioPlay spawn launch_ncmpcpp.sh
hc keybind XF86Mail spawn urxvt -e mutt
hc keybind XF86Calculator spawn urxvt -e tmux -2 attach-session -d -t weechat
 
# tags
TAG_NAMES=( {1..9} )
TAG_KEYS=( {1..9} 0 )
 
hc rename default "${TAG_NAMES[0]}" || true
for i in ${!TAG_NAMES[@]} ; do
hc add "${TAG_NAMES[$i]}"
key="${TAG_KEYS[$i]}"
if ! [ -z "$key" ] ; then
hc keybind $Mod-F$key use_index "$i"
hc keybind "$Mod-Shift-F$key" move_index "$i"
fi
done
 
 
# cycle through tags
hc keybind $Mod-period use_index +1 --skip-visible
hc keybind $Mod-comma use_index -1 --skip-visible
hc keybind $Mod-Right use_index +1 --skip-visible
hc keybind $Mod-Left use_index -1 --skip-visible
 
# layouting
hc keybind $Mod-x remove
hc keybind $Mod-space cycle_layout 1
hc keybind $Mod-u split vertical 0.5
hc keybind $Mod-o split horizontal 0.5
hc keybind $Mod-h floating toggle
hc keybind $Mod-f fullscreen toggle
hc keybind $Mod-p pseudotile toggle
hc keybind $Mod-q close_or_remove
 
# resizing
RESIZESTEP=0.05
hc keybind $Mod-Control-c resize left +$RESIZESTEP
hc keybind $Mod-Control-t resize down +$RESIZESTEP
hc keybind $Mod-Control-s resize up +$RESIZESTEP
hc keybind $Mod-Control-r resize right +$RESIZESTEP
 
# mouse
hc mouseunbind --all
hc mousebind $Mod-Button1 move
hc mousebind $Mod-Button2 resize
hc mousebind $Mod-Button3 zoom
 
# focus
#hc keybind $Mod-BackSpace cycle_monitor
hc keybind $Mod-Tab cycle_all +1
hc keybind $Mod-Shift-Tab cycle_all -1
#hc keybind $Mod-/ cycle
hc keybind $Mod-c focus left
hc keybind $Mod-t focus down
hc keybind $Mod-s focus up
hc keybind $Mod-r focus right
#hc keybind $Mod-i jumpto urgent
hc keybind $Mod-Shift-c shift left
hc keybind $Mod-Shift-t shift down
hc keybind $Mod-Shift-s shift up
hc keybind $Mod-Shift-r shift right
 
# colors
hc set frame_bg_transparent 1
hc set frame_border_active_color ${color["yellow"]}
hc set frame_border_normal_color ${color["gray"]}
hc set frame_bg_normal_color ${color["gray"]}
hc set frame_bg_active_color ${color["yellow"]}
hc set frame_border_width 2
hc set window_border_width 2
hc set window_border_inner_width 0
hc set window_border_normal_color ${color["gray"]}
hc set window_border_active_color ${color["yellow"]}
hc set window_border_urgent_color ${color["red"]}
hc set always_show_frame 1
hc set frame_gap 50
hc set frame_padding 0
# add overlapping window borders
hc set window_gap -2
hc set smart_window_surroundings 0
hc set smart_frame_surroundings 1
 
 
# rules
hc unrule -F
#hc rule class=XTerm tag=3 # move all xterms to tag 3
hc rule focus=on # normally focus new clients
# give focus to most common terminals
hc rule class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)' focus=on
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on
hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK)' manage=off
 
# unlock, just to be sure
hc unlock
 
herbstclient set tree_style '╾│ ├└╼─┐'
 
# do multi monitor setup here, e.g.:
# hc remove_monitor 1
# hc move_monitor 0 1280x1024+0+0
# hc add_monitor 1280x1024+1280+0
 
# find the panel
panel=~/.config/herbstluftwm/panel.sh
[ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh
for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do
# start it on each monitor
$panel $monitor &
done
 
# set background
feh --bg-fill /mnt/raid/images/fonds_ecran/beach_night_waves_shore.jpg
 
#set layouts
panel.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
#p!/bin/bash
 
# disable path name expansion or * will be expanded in the line
# cmd=( $line )
set -f
 
monitor=${1:-0}
geometry=( $(herbstclient monitor_rect "$monitor") )
if [ -z "$geometry" ] ;then
echo "Invalid monitor $monitor"
exit 1
fi
# geometry has the format: WxH+X+Y
x=${geometry[0]}
y=${geometry[1]}
#panel_width=${geometry[2]}
panel_left_width=300
panel_right_width=$((${geometry[2]} - $panel_left_width))
panel_height=24
#font="-*-anonymous pro-*-*-*-*-12-*-*-*-*-*-*-*"
font="-*-tamsyn-medium-*-*-*-13-*-*-*-*-*-*-*"
#bgcolor=$(herbstclient get frame_border_normal_color)
bgcolor='#161B1C'
#selbg=$(herbstclient get window_border_active_color)
selfg='#E5CB85'
selbg='#161B1C'
 
# true if we are using the svn version of dzen2
dzen2_version=$(dzen2 -v 2>&1 | head -n 1 | cut -d , -f 1|cut -d - -f 2)
if [ -z "$dzen2_version" ] ; then
dzen2_svn="true"
else
dzen2_svn="true"
fi
 
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
color[orange]="#CAA073"
 
 
###########
## Icons ##
###########
 
iconpath=/home/polo/.icons/subtle
function icon() {
echo -n "^bg()^fg(${color[${2}]})^i(${iconpath}/${1}.xbm)^fg()^bg()"
}
 
 
##########
## RAID ##
##########
 
function raid() {
raid_monitor=$(grep -e ^md -A1 /proc/mdstat |tail -n1)
echo -n "$(icon drive magenta) ^fg(#707070)${raid_monitor##* }$(df --output=pcent\
/mnt/raid|tail -n1) "
}
 
 
##############
## Podcasts ##
##############
 
function podcast(){
podcast_count=$(find /mnt/raid/podcasts -type f |grep -E \.mp3$ |wc -l)
#echo -n "$(icon phones orange) ^fg(#707070)${podcast_count} "
echo -n "^fg(#707070)${podcast_count} ^fg(${color[orange]})podcasts ^fg(#707070)en attente "
}
 
#########
## RSS ##
#########
 
function rss() {
rsscount=$(wget -qO - "http://rss.domain.tld/public.php?op=getUnread&login=polo")
#rsscount=$(newsbeuter -x print-unread |cut -d " " -f 1)
#echo -n "$(icon rss yellow) ^fg(#707070)${rsscount} "
echo -n "^fg(#707070)${rsscount} ^fg(${color[yellow]})articles ^fg(#707070)non lus "
}
 
 
##########
## Mail ##
##########
 
mail_perso='/home/polo/emails/perso/INBOX/new'
mail_public='/home/polo/emails/public/INBOX/new'
 
function mailcount() {
count=0
if [[ ! -n $(ls ${1}) ]]; then
echo -n "0"
else
count=$(ls -1 ${1} | wc -l)
echo -n ${count}
fi
}
 
function mail() {
#echo -n "$(icon mail green) ^fg(#707070)$(mailcount ${mail_perso})/$(mailcount ${mail_public}) "
echo -n "^fg(#707070)$(mailcount ${mail_perso}) ^fg(${color[green]})emails ^fg(#707070)persos ^fg(#707070)$(mailcount ${mail_public}) ^fg(${color[green]})emails ^fg(#707070)publics "
}
 
 
#########
## IRC ##
#########
irclog=/home/polo/.weechat/logs/perl.highmon.weechatlog
function irc() {
if [[ -f ${irclog} ]]; then
lastline=$(tail -n1 ${irclog})
echo -n "$(icon balloon yellow)^fg(#707070) $(echo -n ${lastline} | cut -d ' ' -f 2,3,4) "
fi
}
 
#########
## MPD ##
#########
 
function m() {
mpc -f %${1}% current #| sed 's/ê/e/gi' | sed 's/è/e/ig' | sed 's/é/e/gi' | sed 's/æ/ae/gi' | sed 's/ä/ae/g' | sed 's/ö/oe/g' | sed 's/ü/ue/g' | sed 's/ï/i/ig' | sed 's/à/a/ig' | sed 's/î/i/ig' | sed 's/…/\.\.\./ig'
}
function nowplaying() {
if [[ -n $(mpc current) ]]; then
echo -n "^ca(1,mpc toggle)^fg(#707070)$(m title) ^fg(${color[red]})par ^fg(#707070)$(m artist)^ca() "
fi
}
 
 
##########
## WiFi ##
##########
 
function wifi() {
echo -n "$(icon wifi_02 green) ^fg(#707070)"
iwlist wlan0 scan | grep 'Quality'| awk '{print $1}' | while read a ; do a=${a#*=}; b=$(( ${a%/*}*100 /${a#*/})) ; echo -n "$b% " ; done
}
 
 
function uniq_linebuffered() {
awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
}
 
herbstclient pad $monitor $panel_height
{
# events:
mpc idleloop player &
mpc_pid=$!
 
while true; do
date +'%H:%M, %Y-%m-%d '
sleep 5 || break
done > >(uniq_linebuffered) &
date_pid=$!
 
herbstclient --idle
kill $mpc_pid $date_pid
 
} 2> /dev/null | {
TAGS=( $(herbstclient tag_status $monitor) )
visible=true
while true ; do
bordercolor="#26221C"
separator="^bg()^fg($selbg)|"
# draw tags
for i in "${TAGS[@]}" ; do
case ${i:0:1} in
'#')
echo -n "^ca(1,herbstclient focus_monitor $monitor &&"'herbstclient use "'${i:1}'")'"^bg($selbg)^fg($selfg) ^i(${iconpath}/full.xbm) ^ca()"
;;
'+')
echo -n "^ca(1,herbstclient focus_monitor $monitor &&"'herbstclient use "'${i:1}'")'"^bg(#9CA668)^fg(#141414) ^i(${iconpath}/full.xbm) ^ca()"
;;
':')
echo -n "^ca(1,herbstclient focus_monitor $monitor &&"'herbstclient use "'${i:1}'")'"^bg()^fg(#ffffff) ^i(${iconpath}/full.xbm) ^ca()"
;;
'!')
echo -n "^ca(1,herbstclient focus_monitor $monitor &&"'herbstclient use "'${i:1}'")'"^bg()^fg(#AF7561) ^i(${iconpath}/full.xbm) ^ca()"
;;
*)
echo -n "^ca(1,herbstclient focus_monitor $monitor &&"'herbstclient use "'${i:1}'")'"^bg()^fg(#ababab) ^i(${iconpath}/empty.xbm) ^ca()"
;;
esac
# if [ ! -z "$dzen2_svn" ] ; then
# echo -n "^ca(1,herbstclient focus_monitor $monitor && "'herbstclient use "'${i:1}'") '"^i(${iconpath}/${i:1}.xbm) ^ca()"
# else
# echo -n " ${i:1} "
# fi
done
#echo -n "$separator"mail
#echo -n "^bg()^fg() ${windowtitle//^/^^}"
echo
right=""
for func in nowplaying mail rss podcast raid ; do
right="${right} $(${func})"
done
# small adjustments
echo >&3 -n "$right"
echo >&3
#echo -n "^pa($(($panel_width - $width)))$right"
# wait for next event
read line || break
cmd=( $line )
# find out event origin
case "${cmd[0]}" in
tag*)
#echo "reseting tags" >&2
TAGS=( $(herbstclient tag_status $monitor) )
;;
date)
#echo "resetting date" >&2
date="${cmd[@]:1}"
;;
quit_panel)
exit
;;
togglehidepanel)
echo "^togglehide()"
if $visible ; then
visible=false
herbstclient pad $monitor 0
else
visible=true
herbstclient pad $monitor $panel_height
fi
;;
reload)
exit
;;
focus_changed|window_title_changed)
windowtitle="${cmd[@]:2}"p
;;
#player)
# ;;
esac
done
} 2> /dev/null \
1> >(dzen2 -w $panel_left_width -x $x -y $y -h $panel_height \
-fn "$font" -ta l -bg "$bgcolor" -fg '#707070') \
3> >(dzen2 -y $y -h $panel_height -fg '#707070' -bg "$bgcolor" \
-fn "$font" -ta r -x $panel_left_width -w $panel_right_width)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.