Skip to content

Instantly share code, notes, and snippets.

@TaylanTatli
Last active September 3, 2020 22:19
Show Gist options
  • Save TaylanTatli/eaf8b66bc7ecd1c2c33d to your computer and use it in GitHub Desktop.
Save TaylanTatli/eaf8b66bc7ecd1c2c33d to your computer and use it in GitHub Desktop.
HerbstluftWM Lemonbar Panel
#!/usr/bin/env bash
# this is a simple config for herbstluftwm
hc() {
herbstclient "$@"
}
hc emit_hook reload
# remove all existing keybindings
hc keyunbind --all
# keybindings
# if you have a super key you will be much happier with Mod set to Mod4
Mod=Mod1 # Use alt as the main modifier
#Mod=Mod4 # Use the super key as the main modifier
#hc keybind $Mod-Shift-q quit
hc keybind $Mod-Shift-q spawn exitbox
hc keybind $Mod-Control-r reload
hc keybind $Mod-Shift-w close
hc keybind $Mod-Return spawn ${TERMINAL:-xterm} # use your $TERMINAL with xterm as fallback
hc keybind $Mod-Shift-Return spawn st -e tmux
hc keybind $Mod-r spawn spawn_rofi
# basic movement
# focusing clients
hc keybind $Mod-Left focus left
hc keybind $Mod-Down focus down
hc keybind $Mod-Up focus up
hc keybind $Mod-Right focus right
# moving clients
hc keybind $Mod-Shift-Left shift left
hc keybind $Mod-Shift-Down shift down
hc keybind $Mod-Shift-Up shift up
hc keybind $Mod-Shift-Right shift right
# splitting frames
# create an empty frame at the specified direction
hc keybind $Mod-v split bottom 0.5
hc keybind $Mod-h split right 0.5
hc keybind $Mod-o split auto
# let the current frame explode into subframes
hc keybind $Mod-Control-space split explode
# resizing frames
resizestep=0.05
hc keybind $Mod-Control-Left resize left +$resizestep
hc keybind $Mod-Control-Down resize down +$resizestep
hc keybind $Mod-Control-Up resize up +$resizestep
hc keybind $Mod-Control-Right resize right +$resizestep
# cycle through tags
hc keybind $Mod-comma use_index +1 --skip-visible
hc keybind $Mod-period use_index -1 --skip-visible
# layouting
hc keybind $Mod-Shift-r remove
hc keybind $Mod-s floating toggle
hc keybind $Mod-f fullscreen toggle
hc keybind $Mod-p pseudotile toggle
hc keybind $Mod-space cycle_layout +1
# mouse
hc mouseunbind --all
hc mousebind $Mod-Button1 move
hc mousebind $Mod-Button2 zoom
hc mousebind $Mod-Button3 resize
# 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-c cycle
hc keybind $Mod-i jumpto urgent
# Volume
hc keybind XF86AudioRaiseVolume spawn pulseaudio-ctl up
hc keybind XF86AudioLowerVolume spawn pulseaudio-ctl down
hc keybind XF86AudioMute spawn pulseaudio-ctl mute
# Misc
hc keybind Print spawn screenshot
hc keybind XF86TouchpadToggle spawn touchpad
# theme
hc attr theme.tiling.reset 1
hc attr theme.floating.reset 1
hc set frame_border_active_color '#222222'
hc set frame_border_normal_color '#101010'
hc set frame_bg_normal_color '#565656'
hc set frame_bg_active_color '#345F0C'
hc set frame_border_width 0
hc set always_show_frame 0
hc set frame_bg_transparent 1
hc set frame_transparent_width 0
hc set frame_gap 1
hc attr theme.active.color '#8c8c88'
hc attr theme.normal.color '#20282c'
hc attr theme.urgent.color orange
hc attr theme.outer_width 2
hc attr theme.inner_color '#20282c'
hc attr theme.border_width 6
hc attr theme.floating.border_width 4
hc attr theme.floating.outer_width 2
hc attr theme.floating.outer_color black
hc attr theme.floating.inner_color '#20282c'
hc attr theme.active.inner_color '#8c8c88'
hc attr theme.active.outer_color black
hc attr theme.background_color '#141414'
hc set window_gap 10
hc set frame_padding 0
hc set smart_window_surroundings 0
hc set smart_frame_surroundings 0
hc set mouse_recenter_gap 0
hc set focus_follows_mouse 1
# tags
#tag_names( term web img herb null foo )
#tag_keys=( {1..6} 0 )
tag_names=( "h" "e" "r" "b" "s" "t" )
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-$key" use_index "$i"
hc keybind "$Mod-Shift-$key" move_index "$i"
fi
done
# rules
hc unrule -F
hc rule class=Firefox tag=h
hc rule class=Steam tag=t
hc rule focus=on # normally focus new clients
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|DESKTOP)' manage=off
# tag modes
hc floating t on
# unlock, just to be sure
hc unlock
herbstclient set tree_style '╾│ ├└╼─┐'
# find the panel
panel=~/.config/herbstluftwm/panel
[ -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 &
"$panel" &
#done
#!/bin/sh
. /home/doublet/.config/herbstluftwm/panel_config
if [ $(pgrep -cx panel) -gt 1 ] ; then
pkill -o panel
fi
trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"
herbstclient pad $MON $PANEL_HEIGHT
clock -i30 -sf 'T%d %b, %a // %H:%M' > "$PANEL_FIFO" &
while [[ true ]]; do
state=$(volume)
if [ $(echo $state | cut -d ' ' -f 1) == "off" ]; then
vol_icon="%{F$CLR6}%{F-}"
vol_percent="off"
echo "V" "%{F$CLR_FG}${vol_icon} ${vol_percent}%{F-}" > "$PANEL_FIFO"
else
vol_percent=$(pulseaudio-ctl | grep "Volume level" | cut -c 39-41)
if [ $vol_percent -gt 66 ]; then
vol_icon=
elif [ $vol_percent -gt 33 ]; then
vol_icon=
else
vol_icon=
fi
echo "V" "%{F$CLR_FG}${vol_icon} ${vol_percent}%{F-}" > "$PANEL_FIFO"
fi
if [ "$(pidof mpd)" ]; then
if [ "$(mpc status |grep playing)" ]; then
currentsong=$(mpc current)
mpd_icon=
playing="$currentsong"
echo "X" "%{F$CLR_FG}${AC}mpc toggle${AB}${mpd_icon} ${AE}$playing "
else
mpd_icon=
playing="Stopped..."
echo "X" "%{F$CLR_FG}${AC}mpc toggle${AB}${mpd_icon} ${AE}$playing "
fi
else
mpd_icon=
playing="Stopped..."
echo "X" "%{F$CLR_FG}${AC}mpc toggle${AB}${mpd_icon} ${AE}$playing "
fi
sleep 1
done > $PANEL_FIFO &
while [[ true ]]; do
mem=$(free -m| grep Mem | awk '{ print int($3/$2*100) }')
read cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
echo "C$cpu"
echo "M$mem"
sleep 3
done > $PANEL_FIFO &
while [[ true ]]; do
QUAL=`iwconfig wlp3s0 | grep 'Link Quality=' | awk '{gsub(/[=/]/," "); print $3}'`
MAX=`iwconfig wlp3s0 | grep 'Link Quality=' | awk '{gsub(/[=/]/," "); print $4}'`
PERC=`echo $QUAL*100/$MAX | bc`
SSID=$(essid -w wlp3s0)
if [[ $PERC -le 15 ]]; then
icon=""
elif [[ $PERC -le 40 ]]; then
icon=""
elif [[ $PERC -le 70 ]]; then
icon=""
elif [[ $PERC -le 100 ]]; then
icon=""
fi
if [ "$SSID" != "" ]; then
essid="$SSID"
else
essid="Bağlantı Yok!"
icon=""
fi
echo "S" "%{F$CLR_FG}$icon ${essid}%{F-}"
sleep 3
done > $PANEL_FIFO &
while [[ true ]]; do
batt=$(battery -n 0)
bat_perc=$(echo $batt | cut -d ' ' -f 2)
bat_status=$(echo $batt | cut -d ' ' -f 1)
if [ $bat_perc -gt 75 ]; then
bat_color=$CLR_FG
bat_symbol=""
elif [ $bat_perc -gt 50 ]; then
bat_color=$CLR_FG
bat_symbol=""
elif [ $bat_perc -gt 30 ]; then
bat_color=$CLR_FG
bat_symbol=""
elif [ $bat_perc -gt 15 ]; then
bat_color=$CLR2
bat_symbol=""
else
bat_color=$CLR1
bat_symbol=""
fi
if [ $bat_status == "Charging" ]; then
bat_symbol=""
fi
echo "B" "%{F$bat_color}$bat_symbol ${bat_perc}%{F-}"
sleep 30
done > $PANEL_FIFO &
while [[ true ]]; do
wm_infos=""
TAGS=( $(herbstclient tag_status $monitor) )
for i in "${TAGS[@]}" ; do
case ${i:0:1} in
'#')
# focused occupied desktop
wm_infos="${wm_infos}%{F$CLR_FG}%{B$CLR0}%{U$CLR1}%{+u}${AC}${goto} ${i:1}${AB} ${i:1} ${AE}%{-u}%{B-}%{F-}"
;;
'+')
# focused free desktop
wm_infos="${wm_infos}%{F$CLR_FG}%{B$CLR0}%{U$CLR1}%{+u}${AC}${goto} ${i:1}${AB} ${i:1} ${AE}%{-u}%{B-}%{F-}"
;;
'!')
# focused urgent desktop
wm_infos="${wm_infos}%{F$CLR_FG}%{B$CLR0}%{U$CLR1}%{+u}${AC}${goto} ${i:1}${AB} ${i:1} ${AE}%{-u}%{B-}%{F-}"
;;
':')
# occupied desktop
wm_infos="${wm_infos}%{F$CLR_FG}%{B$CLR0}%{U$CLR2}%{+u}${AC}${goto} ${i:1}${AB} ${i:1} ${AE}%{-u}%{B-}%{F-}"
;;
*)
# free desktop
wm_infos="${wm_infos}%{F$CLR_FG}%{B$CLR0}%{U$CLR4}%{+u}${AC}${goto} ${i:1}${AB} ${i:1} ${AE}%{-u}%{B-}%{F-}"
;;
esac
shift
done
echo "W$wm_infos"
sleep .3
done > $PANEL_FIFO &
/home/doublet/.config/herbstluftwm/panel_bar < "$PANEL_FIFO" | lemonbar -g $PANEL_GEO -f $FONT_FAMILY -f $ICON_FONT -F $CLR_FG -B $CLR_BG -u 4 -a 11 | while read line; do eval "$line"; done &
wait
#!/bin/sh
. /home/doublet/.config/herbstluftwm/panel_config
while read -r line ; do
case $line in
T*)
# clock output
clock="${AC}~/.config/bspwm/bar/scripts/dzen_cal${AB}%{F$CLR_FG} ${line#?} %{F-}${AE}"
;;
C*)
cpu="%{F$CLR_FG} ${line#?} %{F-}"
;;
M*)
mem="%{F$CLR_FG} ${line#?} %{F-}"
;;
V*)
vol="${line#?}"
;;
S*)
wifi="${line#?}"
;;
B*)
batt="${line#?}"
;;
X*)
mpd="${line#?}"
;;
W*)
wm_infos="${line#?}"
;;
esac
printf "%s\n" "%{l}$mpd%{c}$wm_infos%{r}$cpu$SEP$mem$SEP$wifi$SEP$vol$SEP$batt$SEP$date$SEP$clock"
done
PANEL_FIFO=/tmp/panel-fifo
PANEL_HEIGHT=23
PANEL_GEO=1898x23+11+0
MON=0
FONT_FAMILY='PragmataPro-9:Bold'
ICON_FONT='i3fonticon-10:Regular'
# Colors
CLR0='#ff2e1f1f' #BLACK
CLR1='#ffaa0e50' #RED
CLR2='#ff1dcc9f' #GREEN
CLR3='#ff27c282' #YELLOW
CLR4='#ff7182a8' #BLUE
CLR5='#ffa673a6' #ORANGE
CLR6='#ff6da3a1' #CYAN
CLR7='#ffb7bbbd' #WHITE
CLR_BG='#FF111111'
CLR_FG='#FFECEDEE'
# Commands
AC='%{A:' # start click area
AB=':}' # end click area cmd
AE='%{A}' # end click area
goto='herbstclient use' # go to this desktop
# Icons
DO='' # occupied desktop
DF='' # free desktop
SEP=" "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment