From 3e94a3e724c36267fa2e4039e3759473c59e8510 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Sat, 25 Oct 2014 22:26:54 +0200 Subject: Restructured dotfile repo to take advantage of GNU Stow --- herbstluftwm/.config/herbstluftwm/autostart | 203 +++++++++++++++++++++ herbstluftwm/.config/herbstluftwm/dependencylist | 12 ++ herbstluftwm/.config/herbstluftwm/lock.sh | 7 + herbstluftwm/.config/herbstluftwm/notify.sh | 30 ++++ herbstluftwm/.config/herbstluftwm/panel.sh | 219 +++++++++++++++++++++++ herbstluftwm/.config/herbstluftwm/popup.sh | 60 +++++++ herbstluftwm/.config/herbstluftwm/start.sh | 13 ++ 7 files changed, 544 insertions(+) create mode 100755 herbstluftwm/.config/herbstluftwm/autostart create mode 100644 herbstluftwm/.config/herbstluftwm/dependencylist create mode 100755 herbstluftwm/.config/herbstluftwm/lock.sh create mode 100755 herbstluftwm/.config/herbstluftwm/notify.sh create mode 100755 herbstluftwm/.config/herbstluftwm/panel.sh create mode 100755 herbstluftwm/.config/herbstluftwm/popup.sh create mode 100755 herbstluftwm/.config/herbstluftwm/start.sh (limited to 'herbstluftwm') diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart new file mode 100755 index 0000000..109ea43 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/autostart @@ -0,0 +1,203 @@ +#!/bin/bash + +# this is a simple config for herbstluftwm + +hc() { + herbstclient "$@" +} + +get_x_color() { + xresources=$(cat ~/.Xresources) + color=$(echo $xresources | sed "s/.*\*color$1: \(#[0-9A-Fa-f]*\).*/\1/") + echo $color +} + +hlwm_scripts="$HOME/.config/herbstluftwm" + +#wallpaper +wallpaper=/home/tom/Pictures/fall1.jpg + +#Numix color palette +export WM_LIGHT=$(get_x_color 15) +export WM_LLIGHT=$(get_x_color 7) +export WM_ACCENT=$(get_x_color 9) +export WM_LDARK=$(get_x_color 8) +export WM_DARK=$(get_x_color 0) + +#Panel and window_p +window_p=20 +monitor_w=$(hc list_monitors | sed 's/^[0-9]: \([0-9]*\)x.*$/\1/') +panel_h=24 +panel_w=$(echo "$monitor_w - (2 * $window_p)" | bc) +dmenu_opts="-h $panel_h -w $panel_w -x $window_p -y $window_p -p Run: -nb $WM_DARK -nf $WM_LIGHT -sb $WM_ACCENT -sf $WM_DARK" + +hc emir_hook reload + +# remove all existing keybindings +hc keyunbind --all + +# keybindings +Mod=Mod4 # Use the super key as the main modifier + +hc keybind $Mod-Shift-q quit +hc keybind $Mod-Shift-r reload +hc keybind $Mod-Shift-c close +hc keybind $Mod-Return spawn xterm +hc keybind $Mod-grave spawn dmenu_run $dmenu_opts +hc keybind XF86AudioLowerVolume spawn amixer set Master 5%- +hc keybind XF86AudioRaiseVolume spawn amixer set Master 5%+ + +# 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 +hc keybind $Mod-h focus left +hc keybind $Mod-j focus down +hc keybind $Mod-k focus up +hc keybind $Mod-l 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 +hc keybind $Mod-Shift-h shift left +hc keybind $Mod-Shift-j shift down +hc keybind $Mod-Shift-k shift up +hc keybind $Mod-Shift-l shift right + +# splitting frames +# create an empty frame at the specified direction +hc keybind $Mod-u split bottom 0.5 +hc keybind $Mod-o split right 0.5 +# let the current frame explode into subframes +hc keybind $Mod-Control-space split explode + +# resizing frames +resizestep=0.05 +hc keybind $Mod-Control-h resize left +$resizestep +hc keybind $Mod-Control-j resize down +$resizestep +hc keybind $Mod-Control-k resize up +$resizestep +hc keybind $Mod-Control-l resize right +$resizestep +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 + +# tags +tag_names=( I II III IV V VI VII VIII IX X ) +tag_keys=( {1..9} 0 ) + +# Selecting workspaces +hc keybind Alt-Control-Left use_index -1 +hc keybind Alt-Control-Right use_index +1 +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 + +# cycle through tags +hc keybind $Mod-period use_index +1 --skip-visible +hc keybind $Mod-comma use_index -1 --skip-visible + +# layouting +hc keybind $Mod-r remove +hc keybind $Mod-space cycle_layout 1 +hc keybind $Mod-s floating toggle +hc keybind $Mod-f fullscreen toggle +hc keybind $Mod-p pseudotile toggle + +# 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 +hc set focus_follows_mouse 1 + +# theme +hc attr theme.tiling.reset 1 +hc attr theme.floating.reset 1 +hc set frame_border_active_color $WM_LDARK +hc set frame_border_normal_color $WM_DARK +hc set frame_bg_normal_color $WM_LDARK +hc set frame_bg_active_color $WM_DARK +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 0 + +hc attr theme.active.color $WM_ACCENT +hc attr theme.normal.color $WM_DARK +hc attr theme.urgent.color orange +hc attr theme.inner_width 1 +hc attr theme.inner_color $WM_DARK +hc attr theme.border_width 3 +hc attr theme.floating.border_width 4 +hc attr theme.floating.outer_width 1 +hc attr theme.floating.outer_color $WM_DARK +hc attr theme.active.inner_color $WM_DARK +hc attr theme.active.outer_color $WM_DARK +hc attr theme.background_color $WM_DARK + +hc set window_gap $window_p +hc set frame_padding 0 +hc set smart_window_surroundings 0 +hc set smart_frame_surroundings 1 +hc set mouse_recenter_gap 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 +#hc rule focus=off # normally do not 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|DESKTOP)' manage=off + +# unlock, just to be sure +hc unlock + +herbstclient set tree_style '╾│ ├└╼─┐' + +#Start panel in all monitors +start_panel() { + for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do + "$1" $monitor $panel_h $window_p & + done +} + +# find the panel +panel=$hlwm_scripts/panel.sh +[ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh +if pgrep panel.sh >> /dev/null +then + kill $(pgrep panel.sh) + start_panel $panel +else + start_panel $panel +fi + +$hlwm_scripts/start.sh "xautolock -time 5 -locker $hlwm_scripts/lock.sh" +$hlwm_scripts/start.sh "feh --bg-fill $wallpaper" +$hlwm_scripts/start.sh "compton --config $HOME/.compton" +$hlwm_scripts/start.sh "xrdb -load $HOME/.Xresources" +$hlwm_scripts/start.sh "pulseaudio --start" +$hlwm_scripts/start.sh "dropboxd" +$hlwm_scripts/start.sh "$hlwm_scripts/notify.sh $monitor_w $window_p $panel_h $hlwm_scripts/popup.sh" diff --git a/herbstluftwm/.config/herbstluftwm/dependencylist b/herbstluftwm/.config/herbstluftwm/dependencylist new file mode 100644 index 0000000..a18055d --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/dependencylist @@ -0,0 +1,12 @@ +compton +bar-aint-recursive +bc +wireless_tools +dmenu2 +feh +pulseaudio +alsa-utils +sed +i3lock +scrot +xautolock diff --git a/herbstluftwm/.config/herbstluftwm/lock.sh b/herbstluftwm/.config/herbstluftwm/lock.sh new file mode 100755 index 0000000..04c4638 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/lock.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +SCREENCAP="/tmp/lock.png" +scrot $SCREENCAP +convert -gaussian-blur "12x3" $SCREENCAP $SCREENCAP +i3lock -i $SCREENCAP +rm $SCREENCAP diff --git a/herbstluftwm/.config/herbstluftwm/notify.sh b/herbstluftwm/.config/herbstluftwm/notify.sh new file mode 100755 index 0000000..190d496 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/notify.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +monitor_w=$1 +window_p=$2 +panel_h=$3 + +popup_w=$(echo "$monitor_w - (2 * $window_p)" | bc) +popup_h=$panel_h +popup_x=$window_p +popup_y=$window_p + +popup_opts="-w $popup_w -h $popup_h -x $popup_x -y $popup_y" + +while true; do + + bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity) + bat_stat=$(cat /sys/class/power_supply/BAT1/status) + + if [[ $bat_lvl -le 5 && $bat_stat == "Discharging" ]]; then + $4 -m "Battery level critical: $bat_lvl%%" -u "high" $popup_opts + elif [[ $bat_lvl -eq 10 && $bat_stat == "Discharging" ]]; then + $4 -m "Battery level low: $bat_lvl%%" $popup_opts + elif [[ $bat_lvl -eq 50 && $bat_stat == "Discharging" ]]; then + $4 -m "Battery level at $bat_lvl%%" $popup_opts + elif [[ $bat_lvl -eq 100 && $bat_stat == "Charging" ]]; then + $4 -m "Battery fully charged" + fi + + sleep 60; +done diff --git a/herbstluftwm/.config/herbstluftwm/panel.sh b/herbstluftwm/.config/herbstluftwm/panel.sh new file mode 100755 index 0000000..24d0e12 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/panel.sh @@ -0,0 +1,219 @@ +#!/bin/bash + +hc() { + "${herbstclient_command[@]:-herbstclient}" "$@" ; +} + +add_alpha_channel(){ + echo "$1" | \ + sed "s/.*#\([0-9a-fA-F]*\).*/#ff\1/" +} + +monitor=${1:-0} +panel_height=$2 +padding=$3 + +light=$(add_alpha_channel $WM_LIGHT) +llight=$(add_alpha_channel $WM_LLIGHT) +accent=$(add_alpha_channel $WM_ACCENT) +ldark=$(add_alpha_channel $WM_LDARK) +dark=$(add_alpha_channel $WM_DARK) + +font="-*-fixed-medium-*-*-*-14-*-*-*-*-*-*-*" +#font="" +selected_bg=$accent +normal_bg=$dark +selected_txt=$dark +normal_txt=$light +inactive_txt=$llight + +geometry=( $(herbstclient monitor_rect "$monitor") ) +if [ -z "$geometry" ] ;then + echo "Invalid monitor $monitor" + exit 1 +fi +# geometry has the format W H X Y +x=$(echo "${geometry[0]} + $padding" | bc) +y=$(echo "${geometry[1]} + $padding" | bc) +panel_width=$(echo "${geometry[2]} - (2 * $padding)" | bc) +bar_opts="-g ${panel_width}x${panel_height}+${x}+${y} -f ${font} -u 2 -B ${normal_bg} -F ${normal_txt}" + +hc pad $monitor $(echo "$panel_height + $padding" | bc) + +if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then + # mawk needs "-W interactive" to line-buffer stdout correctly + # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504 + uniq_linebuffered() { + awk -W interactive '$0 != l { print ; l=$0 ; fflush(); }' "$@" + } +else + # other awk versions (e.g. gawk) issue a warning with "-W interactive", so + # we don't want to use it there. + uniq_linebuffered() { + awk '$0 != l { print ; l=$0 ; fflush(); }' "$@" + } +fi + +{ + ### Event generator ### + # \t [...] + # e.g. + # date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29 + + while true ; do + # Volume + if pgrep pulseaudio > /dev/null ; then + volumes=$(\ + amixer get Master | \ + grep "Mono: Playback"\ + ) + vol=$(\ + echo $volumes | \ + sed "s/.*\[\([0-9]*\)%\].*/\1/"\ + ) + if [ -z $vol ] ; then + echo -e "volume\toff" + elif [ $vol -le 0 ] ; then + echo -e "volume\t%{F$normal_txt}Volume muted" + else + echo -e "volume\t%{F$normal_txt}Volume: $vol%%%{F-}" + fi + else + echo -e "volume\toff" + fi + + # Network + iwconfig=$(iwconfig wlp3s0) + if [ -z $iwconfig ] ; then + echo -e "net\toff" + else + ssid=$(\ + echo $iwconfig | \ + sed "s/.*ESSID:\(\".*\"\).*/\1/" | \ + sed "s/.*\(off\/any\).*/\"\1\"/" | \ + sed "s/.*\"\(.*\)\".*/\1/"\ + ) + if [ $ssid = "off/any" ] ; then + ifconf=$ + echo -e "net\t%{F$normal_txt}Net: No connection%{F-}" + else + echo -e "net\t%{F$normal_txt}Net: $ssid%{F-}" + fi + fi + + # Battery + if $(test -e /sys/class/power_supply/BAT1) ; then + bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity) + if [ $bat_lvl -lt 15 ] ; then + bat_color=$accent + else + bat_color=$normal_txt + fi + state=$(cat /sys/class/power_supply/BAT1/status) + echo -e "battery\t%{F$normal_txt}$state: %{F$bat_color}$bat_lvl%{F$normal_txt}%%%{F-}" + else + echo -e "battery\toff" + fi + + # Time + echo -e $(date +$"date\t%{F$normal_txt}%H:%M:%S %{F$inactive_txt}(%d-%m-%Y)%{F-}") + sleep 1 || break + done > >(uniq_linebuffered) & + childpid=$! + hc --idle + kill $childpid +} 2> /dev/null | { + + IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" + visible=true + date="" + volume="" + battery="" + net="" + windowtitle="" + while true ; do + separator="%{F$accent}|%{F-}" + # draw tags + for i in "${tags[@]}" ; do + case ${i:0:1} in + '#') + echo -n "%{U$accent+u}%{B-}%{F$normal_txt}" + ;; + '+') + echo -n "%{B$accent}%{F$normal_bg}" + ;; + ':') + echo -n "%{B-}%{F$normal_txt}" + ;; + '!') + echo -n "%{B$normal_txt}%{F$normal_bg}" + ;; + *) + echo -n "%{B-}%{F$inactive_txt}" + ;; + esac + echo -n "%{A:tag,${i:1}:} ${i:1} %{A}%{F-}%{B-}%{U-u}" + done + echo -n "$separator" + echo -n "%{B-}%{F-} ${windowtitle//^/^^}" + + #Right part of panel + right="$volume$net$battery$date " + echo -n "%{r}$right" + echo + + # wait for next event + IFS=$'\t' read -ra cmd || break + case "${cmd[0]}" in + tag*) + #echo "resetting tags" >&2 + IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" + ;; + volume) + volume="${cmd[@]:1}" + if [ $volume == "off" ] ; then + volume="" + else + volume="$volume $separator%{B-} " + fi + ;; + net) + net="${cmd[@]:1}" + if [ $net = "off" ] ; then + net="" + else + net="$net $separator%{B-} " + fi + ;; + battery) + battery="${cmd[@]:1}" + if [ $battery == "off" ] ; then + battery="" + else + battery="$battery $separator%{B-} " + fi + ;; + date) + #echo "resetting date" >&2 + date="${cmd[@]:1}" + ;; + focus_changed|window_title_changed) + windowtitle="${cmd[@]:2}" + ;; + esac + done +} 2> /dev/null | bar $bar_opts | { + #Handle clickable areas + while read line; do + IFS=',' read -a c <<< $(echo $line) + case "${c[0]}" in + tag) + herbstclient use "${c[1]}" + echo "herbstclient use \"${c[1]}\"" + ;; + *) + echo "${c[0]}: not valid command" + ;; + esac + done +} diff --git a/herbstluftwm/.config/herbstluftwm/popup.sh b/herbstluftwm/.config/herbstluftwm/popup.sh new file mode 100755 index 0000000..41c5e9c --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/popup.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +help () { + echo -e "Usage: popup.sh [OPTIONS]" + echo -e "Spawns a popup for a certain amount of time" + echo -e "" + echo -e "Options:" + echo -e " -m MESSAGE\t\tSpecifies message to be displayed" + echo -e " -t TIMEOUT\t\tAmount of time in seconds the popup is displayed" +} + +add_alpha_channel(){ + echo "$1" | \ + sed "s/.*#\([0-9a-fA-F]*\).*/#ff\1/" +} + +timeout=10 +message="" +x=0 +y=0 +width=120 +height=90 +urgency="info" + +while getopts ":m:t:x:y:w:h:u:" opt; do + case $opt in + m) message=$OPTARG ;; + t) timeout=$OPTARG ;; + x) x=$OPTARG ;; + y) y=$OPTARG ;; + w) width=$OPTARG ;; + h) height=$OPTARG ;; + u) urgency=$OPTARG ;; + esac +done + +if test ! $message; then + help +else + light=$(add_alpha_channel $WM_LIGHT) + llight=$(add_alpha_channel $WM_LLIGHT) + accent=$(add_alpha_channel $WM_ACCENT) + ldark=$(add_alpha_channel $WM_LDARK) + dark=$(add_alpha_channel $WM_DARK) + font="-*-fixed-medium-*-*-*-$(echo "$height - 10" | bc)-*-*-*-*-*-*-*" + bar_opts="-f ${font} -B $dark -F $light -g ${width}x${height}+${x}+${y} -u 2" + + t=$(date +%T) + + if [ $urgency == "info" ]; then + prefix="Info:" + elif [ $urgency == "high" ]; then + prefix="!!WARNING:" + fi + + { + echo "%{F$accent} $prefix %{F$light}$message %{F$llight}($t)%{F-}" + sleep $timeout + } | bar $bar_opts +fi diff --git a/herbstluftwm/.config/herbstluftwm/start.sh b/herbstluftwm/.config/herbstluftwm/start.sh new file mode 100755 index 0000000..f10fca6 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/start.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +opts=($@) + +program=$(echo ${opts[0]} | sed 's/^.*\/\(.*\)/\1/') + +if pgrep $program >> /dev/null +then + killall $program + ${opts[@]} & +else + ${opts[@]} & +fi -- cgit v1.2.3