From ca57483a782246739ea5356ac1102a611b062814 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Sun, 29 Jul 2018 23:59:03 +0200 Subject: [PATCH] fix hc alias - add bapyrus --- autostart | 13 ++-- bindings.sh | 97 +++++++++++++++--------------- panel.sh | 163 +-------------------------------------------------- rules.sh | 18 +++--- statusbar.sh | 2 +- styling.sh | 38 ++++++------ tray.sh | 2 +- 7 files changed, 83 insertions(+), 250 deletions(-) mode change 100755 => 120000 panel.sh diff --git a/autostart b/autostart index c9bb3f5..ea3160c 100755 --- a/autostart +++ b/autostart @@ -1,5 +1,4 @@ -#!/bin/sh -hc=herbstclient +#!/usr/bin/env bash CFGDIR=$HOME/.config/herbstluftwm @@ -11,22 +10,22 @@ pkill conky pkill urxvtd pkill udiskie -hc emit_hook reload +herbstclient emit_hook reload ${CFGDIR}/bindings.sh ${CFGDIR}/rules.sh ${CFGDIR}/styling.sh -$hc set tree_style '╾│ ├└╼─┐' -$hc unlock -$hc detect_monitors +herbstclient set tree_style '╾│ ├└╼─┐' +herbstclient unlock +herbstclient detect_monitors panel_height=20 statusbar_height=20 for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do # start it on each monitor - $hc pad $monitor $panel_height 0 $statusbar_height 0 + herbstclient pad $monitor $panel_height 0 $statusbar_height 0 ${CFGDIR}/panel.sh $monitor & ${CFGDIR}/statusbar.sh $monitor & done diff --git a/bindings.sh b/bindings.sh index 8970d1d..a567724 100755 --- a/bindings.sh +++ b/bindings.sh @@ -1,80 +1,77 @@ -#!/bin/sh - -hc=herbstclient - -$hc keyunbind --all +#!/bin/bash +herbstclient keyunbind --all # keybindings Mod=Mod4 -$hc keybind $Mod-Control-q quit -$hc keybind $Mod-Shift-q close -$hc keybind $Mod-Shift-r reload +herbstclient keybind $Mod-Control-q quit +herbstclient keybind $Mod-Shift-q close +herbstclient keybind $Mod-Shift-r reload # tags TAG_NAMES=( {1..9} 0 ) TAG_KEYS=( {1..9} 0 ) -$hc rename default "${TAG_NAMES[0]}" || true +herbstclient rename default "${TAG_NAMES[0]}" || true for i in ${!TAG_NAMES[@]} ; do - $hc add "${TAG_NAMES[$i]}" + herbstclient 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" + herbstclient keybind "$Mod-$key" use_index "$i" + herbstclient 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 -$hc keybind $Mod-Right use_index +1 --skip-visible -$hc keybind $Mod-Left use_index -1 --skip-visible -$hc keybind $Mod-minus use_previous +herbstclient keybind $Mod-period use_index +1 --skip-visible +herbstclient keybind $Mod-comma use_index -1 --skip-visible +herbstclient keybind $Mod-Right use_index +1 --skip-visible +herbstclient keybind $Mod-Left use_index -1 --skip-visible +herbstclient keybind $Mod-minus use_previous # layouting -$hc keybind $Mod-r remove +herbstclient keybind $Mod-r remove -$hc keybind $Mod-space cycle_layout 1 +herbstclient keybind $Mod-space cycle_layout 1 -$hc keybind $Mod-e split explode +herbstclient keybind $Mod-e split explode -$hc keybind $Mod-u split vertical 0.5 -$hc keybind $Mod-Shift-u split vertical 0.66 +herbstclient keybind $Mod-u split vertical 0.5 +herbstclient keybind $Mod-Shift-u split vertical 0.66 -$hc keybind $Mod-o split horizontal 0.5 -$hc keybind $Mod-Shift-o split horizontal 0.666 +herbstclient keybind $Mod-o split horizontal 0.5 +herbstclient keybind $Mod-Shift-o split horizontal 0.666 -$hc keybind $Mod-s floating toggle -$hc keybind $Mod-f fullscreen toggle -$hc keybind $Mod-p pseudotile toggle +herbstclient keybind $Mod-s floating toggle +herbstclient keybind $Mod-f fullscreen toggle +herbstclient keybind $Mod-p pseudotile toggle # resizing RESIZESTEP=0.02 -$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 +herbstclient keybind $Mod-Control-h resize left +$RESIZESTEP +herbstclient keybind $Mod-Control-j resize down +$RESIZESTEP +herbstclient keybind $Mod-Control-k resize up +$RESIZESTEP +herbstclient keybind $Mod-Control-l resize right +$RESIZESTEP # mouse in floating mode -$hc mouseunbind --all -$hc mousebind $Mod-Button1 move -$hc mousebind $Mod-Button2 zoom -$hc mousebind $Mod-Button3 resize +herbstclient mouseunbind --all +herbstclient mousebind $Mod-Button1 move +herbstclient mousebind $Mod-Button2 zoom +herbstclient mousebind $Mod-Button3 resize # focus -$hc set focus_follows_mouse 1 -$hc rule focus=on -$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-h focus left -$hc keybind $Mod-j focus down -$hc keybind $Mod-k focus up -$hc keybind $Mod-l focus right -$hc keybind $Mod-i jumpto urgent -$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 +herbstclient set focus_follows_mouse 1 +herbstclient rule focus=on +herbstclient keybind $Mod-BackSpace cycle_monitor +herbstclient keybind $Mod-Tab cycle_all +1 +herbstclient keybind $Mod-Shift-Tab cycle_all -1 +herbstclient keybind $Mod-c cycle +herbstclient keybind $Mod-h focus left +herbstclient keybind $Mod-j focus down +herbstclient keybind $Mod-k focus up +herbstclient keybind $Mod-l focus right +herbstclient keybind $Mod-i jumpto urgent +herbstclient keybind $Mod-Shift-h shift left +herbstclient keybind $Mod-Shift-j shift down +herbstclient keybind $Mod-Shift-k shift up +herbstclient keybind $Mod-Shift-l shift right diff --git a/panel.sh b/panel.sh deleted file mode 100755 index c5c1f53..0000000 --- a/panel.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/bash - -source ~/.config/herbstluftwm/settings.sh - -# disable path name expansion or * will be expanded in the line -# cmd=( $line ) -set -f - -monitor=${1:-0} -monGeomitry=( $(herbstclient monitor_rect "$monitor") ) -if [ -z "$monGeomitry" ] ;then - echo "Invalid monitor $monitor" - exit 1 -fi - -# monGeomitry has the format: WxH+X+Y -x=${monGeomitry[0]} -y=${monGeomitry[1]} -panel_width=$((${monGeomitry[2]})) -panel_height=20 - -# reserve space for tray on first monitor -if [ $monitor -eq 0 ] ; then - panel_width=$(($panel_width - 100)) -fi - -panelGeometry=${panel_width}x${panel_height}+${x}+${y} - -textellipsis() { - awk -v len=100 '{ if (length($0) > len) print substr($0, 1, len-3) "..."; else print; }' -} - -volume() { - LEVEL=$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*\)%\].*/\1/') - if [ "$LEVEL" -gt "49" ] ; then - echo -en '\uf028'; - elif [ "$LEVEL" -gt "0" ] ; then - echo -en '\uf027'; - else - echo -en '\uf026'; - fi - echo " ${LEVEL}%" -} - -# events -{ - # now playing - mpc idleloop player | cat & - mpc_pid=$! - - # volume - while true ; do - echo -e "vol " $(volume) - sleep 1 || break - done > >(uniq_linebuffered) & - vol_pid=$! - - # date - while true ; do - date +'date_min %Y-%m-%d %H:%M' - sleep 1 || break - done > >(uniq_linebuffered) & - date_pid=$! - - # herbstluftwm - herbstclient --idle - - # exiting; kill stray event-emitting processes - kill $mpc_pid $vol_pid $date_pid -} 2> /dev/null | { - TAGS=( $(herbstclient tag_status $monitor) ) - unset TAGS[${#TAGS[@]}] - time="" - song="" - windowtitle="" - visible=true - - while true ; do - echo -n "%{l}%{F-}" - for i in "${TAGS[@]}" ; do - case ${i:0:1} in - '#') # current tag - echo -n "%{U$active}%{+u}" - ;; - '+') # active on other monitor - echo -n "%{U$activeOnMontior}%{+u}" - ;; - ':') - echo -n "%{F$notempty}" - ;; - '!') # urgent tag - echo -n "%{U$urgent}%{+u}" - ;; - *) - echo -n "%{F$notused}" - ;; - esac - echo -n "%{A:select_tag ${i:1}:}" - echo -n " ${i:1} " - echo -n "%{A}" - echo -n "%{-u}%{F-}%{B-}" - done - - # center window title - echo -n "%{c}$(echo ${windowtitle//^/^^} | textellipsis) " - - # align right - echo -n "%{r}" - if [ -n "$song" ] ; then - echo -n "$song" "$song2" - fi - echo -en " $volume " - echo -en "\uf133 $date" - echo " " - - # wait for next event - read line || break - cmd=( $line ) - # find out event origin - case "${cmd[0]}" in - tag*) - TAGS=( $(herbstclient tag_status $monitor) ) - unset TAGS[${#TAGS[@]}] - ;; - mpd_player|player) - song="$(mpc -f %artist% current)" - song2="$(mpc -f %title% current)" - ;; - vol) - volume="${cmd[@]:1}" - ;; - date_min) - date="${cmd[@]:1}" - ;; - focus_changed|window_title_changed) - windowtitle="${cmd[@]:2}" - ;; - quit_panel) - exit - ;; - reload) - exit - ;; - esac - done -} 2> /dev/null \ - | lemonbar \ - -g $panelGeometry \ - -f "$font" \ - -B "$bgcolor" -F "$fgcolor" \ - -u 2 \ - | while read line; do - set $line - case "$1" in - select_tag ) - # make sure the current monitor is focused - herbstclient focus_monitor $monitor - herbstclient use $2 - ;; - esac - done - diff --git a/panel.sh b/panel.sh new file mode 120000 index 0000000..4cafc11 --- /dev/null +++ b/panel.sh @@ -0,0 +1 @@ +/usr/bin/barpyrus \ No newline at end of file diff --git a/rules.sh b/rules.sh index 473d44e..eb8fc48 100755 --- a/rules.sh +++ b/rules.sh @@ -1,13 +1,13 @@ -#!/bin/sh +#!/usr/bin/env bash -alias hc=herbstclient +set -e # rules -hc unrule -F -#hc rule class=XTerm tag=3 # move all xterms to tag 3 -hc rule focus=off # normally do not focus new clients +herbstclient unrule -F +#herbstclient rule class=XTerm tag=3 # move all xterms to tag 3 +herbstclient 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)' manage=off +herbstclient rule class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)' focus=on +herbstclient rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on +herbstclient rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on +herbstclient rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK)' manage=off diff --git a/statusbar.sh b/statusbar.sh index 66b6c0b..1e9cdda 100755 --- a/statusbar.sh +++ b/statusbar.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source ~/.config/herbstluftwm/settings.sh # disable path name expansion or * will be expanded in the line diff --git a/styling.sh b/styling.sh index e59bba1..5efe009 100755 --- a/styling.sh +++ b/styling.sh @@ -1,30 +1,28 @@ -#!/bin/sh -hc=herbstclient - +#!/bin/bash -x CFGDIR=$HOME/.config/herbstluftwm $CFGDIR/wallpaper.sh # frame/window styling -$hc set frame_border_active_color '#eee8d5' -$hc set frame_border_normal_color '#475152' -$hc set frame_bg_transparent 1 -$hc set frame_border_width 1 -$hc set frame_active_opacity 80 -$hc set frame_normal_opacity 80 -$hc set frame_gap 4 -$hc set frame_padding 0 -$hc set always_show_frame 1 -$hc set smart_frame_surroundings 1 +herbstclient set frame_border_active_color '#eee8d5' +herbstclient set frame_border_normal_color '#475152' +herbstclient set frame_bg_transparent 1 +herbstclient set frame_border_width 1 +herbstclient set frame_active_opacity 80 +herbstclient set frame_normal_opacity 80 +herbstclient set frame_gap 4 +herbstclient set frame_padding 0 +herbstclient set always_show_frame 1 +herbstclient set smart_frame_surroundings 1 -$hc set window_border_width 2 -$hc set window_border_inner_width 0 -$hc set window_border_normal_color '#0a1b22' -$hc set window_border_active_color '#d9e5e7' -$hc set window_gap 0 -$hc set smart_window_surroundings 1 +herbstclient set window_border_width 2 +herbstclient set window_border_inner_width 0 +herbstclient set window_border_normal_color '#0a1b22' +herbstclient set window_border_active_color '#d9e5e7' +herbstclient set window_gap 0 +herbstclient set smart_window_surroundings 1 -$hc set mouse_recenter_gap 0 +herbstclient set mouse_recenter_gap 0 diff --git a/tray.sh b/tray.sh index ce9e69b..40e6fb5 100755 --- a/tray.sh +++ b/tray.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source ~/.config/herbstluftwm/settings.sh