diff options
| author | Peter Son Struschka <me@peter-struschka.com> | 2020-08-30 20:56:36 +0800 |
|---|---|---|
| committer | Peter Son Struschka <me@peter-struschka.com> | 2020-08-30 20:58:04 +0800 |
| commit | 37dd411698bd6eae8365260dde39b8ae9c7cbd36 (patch) | |
| tree | 978dd6ea3e72a86e4a3e0314b86d5137fc394785 /herbstluftwm | |
| parent | a1d6fc2f3e6ab041cc51cb085ac59a646a126d25 (diff) | |
| download | dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.gz dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.bz2 dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.lz dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.xz dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.zst dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.zip | |
all: overhaul, move dotfile specifics to .local/share/dotfiles and more
Diffstat (limited to 'herbstluftwm')
| -rwxr-xr-x | herbstluftwm/.config/herbstluftwm/autostart | 35 | ||||
| -rwxr-xr-x | herbstluftwm/.config/herbstluftwm/panel.sh | 77 | ||||
| -rwxr-xr-x | herbstluftwm/.local/bin/q3terminal.sh | 97 | ||||
| -rwxr-xr-x | herbstluftwm/.local/bin/scratchpad.sh | 70 | ||||
| -rwxr-xr-x | herbstluftwm/.local/bin/statusbar/herbstluftwm_tag_list | 14 | ||||
| l--------- | herbstluftwm/.local/share/config-files/herbstluftwm-panel | 1 | ||||
| l--------- | herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm | 1 | ||||
| l--------- | herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm-panel | 1 |
8 files changed, 284 insertions, 12 deletions
diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart index ab844a9..7605dd2 100755 --- a/herbstluftwm/.config/herbstluftwm/autostart +++ b/herbstluftwm/.config/herbstluftwm/autostart @@ -10,7 +10,7 @@ hc emit_hook reload if hc silent new_attr bool my_not_first_autostart; then [ ! "$(pidof -x picom)" ] && picom & - xset s 300 5 + xset s 600 5 [ ! "$(pidof -x xss-lock)" ] && xss-lock -n /usr/lib/xsecurelock/dimmer -l -- xsecurelock & fi @@ -23,6 +23,7 @@ hc keyunbind --all # 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 +ModAlt=Mod1 hc keybind $Mod-Shift-e quit hc keybind $Mod-Shift-r reload @@ -92,6 +93,8 @@ done hc keybind $Mod-period use_index +1 --skip-visible hc keybind $Mod-comma use_index -1 --skip-visible +hc keybind $Mod-b use_previous + # layouting hc keybind $Mod-r remove hc keybind $Mod-s floating toggle @@ -102,10 +105,16 @@ hc keybind $Mod-p pseudotile toggle # layouts, if the layout change wouldn't affect the actual window positions. # I.e. if there are two windows within a frame, the grid layout is skipped. hc keybind $Mod-space \ - or , and . compare tags.focus.curframe_wcount = 2 \ + or , and . emit_hook layout_changed \ + . compare tags.focus.curframe_wcount = 2 \ . cycle_layout +1 vertical horizontal max vertical grid \ , cycle_layout +1 +hc keybind $ModAlt-Tab spawn rofi -show window + +# scratchpad +hc keybind $Mod-grave spawn ~/.local/bin/scratchpad.sh + # media hc keybind XF86AudioLowerVolume spawn change-vol - hc keybind XF86AudioRaiseVolume spawn change-vol + @@ -129,6 +138,14 @@ hc mousebind $Mod-Button3 resize # focus hc keybind $Mod-BackSpace cycle_monitor +# Swap tag with next monitor +hc keybind $Mod-Shift-BackSpace chain \ + , new_attr string my_prev_monitor_tag \ + , substitute T monitors.focus.tag \ + set_attr my_prev_monitor_tag T \ + , cycle_monitor \ + , substitute T my_prev_monitor_tag \ + use T hc keybind $Mod-Tab cycle_all +1 hc keybind $Mod-Shift-Tab cycle_all -1 hc keybind $Mod-c cycle @@ -166,6 +183,8 @@ hc set smart_window_surroundings off hc set smart_frame_surroundings on hc set mouse_recenter_gap 0 +hc set focus_crosses_monitor_boundaries off + # rules hc unrule -F #hc rule class=XTerm tag=3 # move all xterms to tag 3 @@ -178,6 +197,10 @@ hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off hc rule class='jetbrains-toolbox' floating=on +hc rule class='jetbrains-idea' instance='jetbrains-idea' title='win0' floating=on +hc rule class=Steam instance=Steam title~'Steam( .*)' +hc rule class=Steam instance=Steam title~'(.*)List(.*)' +hc rule instance=scratchpad tag=scratchpad hc set tree_style '╾│ ├└╼─┐' @@ -194,5 +217,11 @@ panel=~/.config/herbstluftwm/panel.sh [ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh for monitor in $(hc list_monitors | cut -d: -f1) ; do # start it on each monitor - "$panel" "$monitor" & + hc spawn "$panel" "$monitor" +done +killall -q stalonetray +while pgrep -u "$UID" -x stalonetray >/dev/null; do + sleep 1 done +sleep 5 +hc spawn stalonetray --geometry 1x1+1250+0 --window-layer top -c "$XDG_CONFIG_HOME/stalonetray/stalonetrayrc" diff --git a/herbstluftwm/.config/herbstluftwm/panel.sh b/herbstluftwm/.config/herbstluftwm/panel.sh index 6088aeb..ebdd59a 100755 --- a/herbstluftwm/.config/herbstluftwm/panel.sh +++ b/herbstluftwm/.config/herbstluftwm/panel.sh @@ -83,15 +83,40 @@ hc pad $monitor $panel_height sleep 5 || break done > >(uniq_linebuffered) & batterychildpid=$! + while true ; do + cpu_percentage=$("${HOME}"/.local/bin/statusbar/cpu) + echo -e "cpu\t$cpu_percentage%" + sleep 2 || break + done > >(uniq_linebuffered) & + cpuchildpid=$! + while true ; do + mem_percentage=$("${HOME}"/.local/bin/statusbar/memory | cut -d ' ' -f2) + echo -e "memory\t$mem_percentage%" + sleep 2 || break + done > >(uniq_linebuffered) & + memchildpid=$! + while true ; do + swapusage=$("${HOME}"/.local/bin/statusbar/swap | awk '{printf "%.2fG/%dG", $4, $1}') + echo -e "swap\t$swapusage" + sleep 2 || break + done > >(uniq_linebuffered) & + swapchildpid=$! hc --idle kill $datechildpid kill $batterychildpid + kill $cpuchildpid + kill $memchildpid + kill $swapchildpid } 2> /dev/null | { IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" visible=true date="" battery="status" + cpu="" + memory="" + swap="" windowtitle="" + layout="" while true ; do ### Output ### @@ -101,17 +126,28 @@ hc pad $monitor $panel_height separator="^bg()^fg($selbg)|" # draw tags for i in "${tags[@]}" ; do + # don't render these hidden tags + case ${i:1} in + 'scratchpad') + continue ;; + esac case ${i:0:1} in - '#') + '#') # Tag in focus on this monitor echo -n "^bg($selbg)^fg($selfg)" ;; - '+') + '%') # tag in focus on other monitor echo -n "^bg(#9CA668)^fg(#141414)" ;; - ':') + '-') # tag viewed on other monitor + echo -n "^bg(#9CA668)^fg(#141414)" + ;; + '+') # tag viewed on this monitor + echo -n "^bg(#9CA668)^fg(#141414)" + ;; + ':') # tag not emtpy echo -n "^bg()^fg(#ffffff)" ;; - '!') + '!') # tag urgent echo -n "^bg(#FF0675)^fg(#141414)" ;; *) @@ -127,13 +163,13 @@ hc pad $monitor $panel_height echo -n " ${i:1} " fi done - echo -n "$separator" + echo -n "$separator [$layout] $separator" echo -n "^bg()^fg() ${windowtitle//^/^^}" # small adjustments - right="$separator $battery $separator^bg() $date $separator" + right="$separator cpu: $cpu $separator mem: $memory $separator swap: $swap $separator $battery $separator^bg() $date $separator" right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g') # get width of right aligned text.. and add some space.. - width=$($textwidth "$font" "$right_text_only ") + width=$($textwidth "$font" "$right_text_only ") echo -n "^pa($(($panel_width - $width)))$right" echo @@ -149,7 +185,7 @@ hc pad $monitor $panel_height IFS=$'\t' read -ra cmd || break # log events for debugging - #echo "${cmd[@]}" >> /tmp/panel_${monitor}.log + echo "${cmd[@]}" >> /tmp/panel_${monitor}.log # find out event origin case "${cmd[0]}" in @@ -164,6 +200,15 @@ hc pad $monitor $panel_height battery) battery="${cmd[@]:1}" ;; + cpu) + cpu="${cmd[@]:1}" + ;; + memory) + memory="${cmd[@]:1}" + ;; + swap) + swap="${cmd[@]:1}" + ;; quit_panel) exit ;; @@ -189,6 +234,20 @@ hc pad $monitor $panel_height ;; focus_changed|window_title_changed) windowtitle="${cmd[@]:2}" + ;& + layout_changed) + currenttag=$(hc tag_status | tr '\t' '\n' | sed -n 's/#//p') + focusedtaglayout=$(hc layout "$currenttag" @ | awk '{print $2}' | sed 's/://') + case "$focusedtaglayout" in + vertical) + layout="V" ;; + horizontal) + layout="H" ;; + max) + layout="M" ;; + grid) + layout="G" ;; + esac ;; #player) # ;; @@ -201,4 +260,4 @@ hc pad $monitor $panel_height } 2> /dev/null | dzen2 -w $panel_width -x $x -y $y -fn "$font" -h $panel_height \ -e "button3=;button4=exec:$hc_quoted use_index +1;button5=exec:$hc_quoted use_index -1;button7=exec:$hc_quoted use_index +1;button6=exec:$hc_quoted use_index -1" \ - -ta l -bg "$bgcolor" -fg '#efefef' + -ta l -bg "$bgcolor" -fg '#efefef' -dock -m diff --git a/herbstluftwm/.local/bin/q3terminal.sh b/herbstluftwm/.local/bin/q3terminal.sh new file mode 100755 index 0000000..e69b5ee --- /dev/null +++ b/herbstluftwm/.local/bin/q3terminal.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash + +# a q3-like (or yakuake-like) terminal for arbitrary applications. +# +# this lets a new monitor called "q3terminal" scroll in from the top into the +# current monitor. There the "scratchpad" will be shown (it will be created if +# it doesn't exist yet). If the monitor already exists it is scrolled out of +# the screen and removed again. +# +# Warning: this uses much resources because herbstclient is forked for each +# animation step. +# +# If a tag name is supplied, this is used instead of the scratchpad + +tag="${1:-scratchpad}" +hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;} + +termwidth_percent=${WIDTH_PERC:-100} +mrect=( $(hc monitor_rect -p "" ) ) +termwidth=$(( (${mrect[2]} * termwidth_percent) / 100 )) +termheight=${HEIGHT_PIXELS:-400} + +rect=( + $termwidth + $termheight + $(( ${mrect[0]} + (${mrect[2]} - termwidth) / 2 )) + $(( ${mrect[1]} - termheight )) +) + +y_line=${mrect[1]} + + +hc add "$tag" + + +monitor=dropdown + +exists=false +if ! hc add_monitor $(printf "%dx%d%+d%+d" "${rect[@]}") \ + "$tag" $monitor 2> /dev/null ; then + exists=true +else + # remember which monitor was focused previously + hc chain \ + , new_attr string monitors.by-name."$monitor".my_prev_focus \ + , substitute M monitors.focus.index \ + set_attr monitors.by-name."$monitor".my_prev_focus M +fi + +update_geom() { + local geom=$(printf "%dx%d%+d%+d" "${rect[@]}") + hc move_monitor "$monitor" $geom +} + +steps=${ANIMATION_STEPS:-1} +interval=${ANIMATION_INTERVAL:-0.01} + +animate() { + progress=( "$@" ) + for i in "${progress[@]}" ; do + rect[3]=$((y_line - (i * termheight) / steps)) + update_geom + sleep "$interval" + done +} + +show() { + hc lock + hc raise_monitor "$monitor" + hc focus_monitor "$monitor" + hc unlock + hc lock_tag "$monitor" + animate $(seq $steps -1 0) +} + +hide() { + rect=( $(hc monitor_rect "$monitor" ) ) + local tmp=${rect[0]} + rect[0]=${rect[2]} + rect[2]=${tmp} + local tmp=${rect[1]} + rect[1]=${rect[3]} + rect[3]=${tmp} + termheight=${rect[1]} + y_line=${rect[3]} # height of the upper screen border + + animate $(seq 0 +1 $steps) + # if q3terminal still is focused, then focus the previously focused monitor + # (that mon which was focused when starting q3terminal) + hc substitute M monitors.by-name."$monitor".my_prev_focus \ + and + compare monitors.focus.name = "$monitor" \ + + focus_monitor M + hc remove_monitor "$monitor" +} + +[ $exists = true ] && hide || show + diff --git a/herbstluftwm/.local/bin/scratchpad.sh b/herbstluftwm/.local/bin/scratchpad.sh new file mode 100755 index 0000000..d168ad7 --- /dev/null +++ b/herbstluftwm/.local/bin/scratchpad.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# a i3-like scratchpad for arbitrary applications. +# +# this lets a new monitor called "scratchpad" appear in from the top into the +# current monitor. There the "scratchpad" will be shown (it will be created if +# it doesn't exist yet). If the monitor already exists it is scrolled out of +# the screen and removed again. +# +# Warning: this uses much resources because herbstclient is forked for each +# animation step. +# +# If a tag name is supplied, this is used instead of the scratchpad + +tag="${1:-scratchpad}" +hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;} +#scratchpad=(alacritty --title "$tag" --class "scratchpad") +scratchpad=(urxvt -title "$tag" -name "scratchpad") +#scratchpad=(xterm -title "$tag" -name "scratchpad") + +#mrect=( $(hc monitor_rect "") ) +read -r -a mrect < <(hc monitor_rect "") + +width=${mrect[2]} +height=${mrect[3]} + +rect=( + $((width/2)) + $((height/2)) + $((mrect[0]+(width/4))) + $((mrect[1]+(height/4))) +) + +hc add "$tag" + +monitor=scratchpad + +exists=false +if ! hc add_monitor $(printf "%dx%d%+d%+d" "${rect[@]}") \ + "$tag" $monitor 2> /dev/null ; then + exists=true +else + # remember which monitor was focused previously + hc chain \ + , new_attr string monitors.by-name."$monitor".my_prev_focus \ + , substitute M monitors.focus.index \ + set_attr monitors.by-name."$monitor".my_prev_focus M +fi + +show() { + [ "$(hc attr tags.by-name."$tag".client_count)" = "0" ] && hc spawn "${scratchpad[@]}" + hc lock + hc raise_monitor "$monitor" + hc focus_monitor "$monitor" + hc unlock + hc lock_tag "$monitor" +} + +hide() { + # if q3terminal still is focused, then focus the previously focused monitor + # (that mon which was focused when starting q3terminal) + hc substitute M monitors.by-name."$monitor".my_prev_focus \ + and + compare monitors.focus.name = "$monitor" \ + + focus_monitor M + hc remove_monitor "$monitor" +} + +# shellcheck disable=SC2015 +[ $exists = true ] && hide || show + diff --git a/herbstluftwm/.local/bin/statusbar/herbstluftwm_tag_list b/herbstluftwm/.local/bin/statusbar/herbstluftwm_tag_list new file mode 100755 index 0000000..41c3569 --- /dev/null +++ b/herbstluftwm/.local/bin/statusbar/herbstluftwm_tag_list @@ -0,0 +1,14 @@ +#!/bin/env bash + +hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;} +monitor=${1:-0} + +{ + hc --idle +} 2> /dev/null | { + IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" + while true ; do + for i in "${tags[@]}" ; do + case + + diff --git a/herbstluftwm/.local/share/config-files/herbstluftwm-panel b/herbstluftwm/.local/share/config-files/herbstluftwm-panel new file mode 120000 index 0000000..439ccbe --- /dev/null +++ b/herbstluftwm/.local/share/config-files/herbstluftwm-panel @@ -0,0 +1 @@ +../../../.config/herbstluftwm/panel.sh
\ No newline at end of file diff --git a/herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm b/herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm new file mode 120000 index 0000000..a3dfe2b --- /dev/null +++ b/herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm @@ -0,0 +1 @@ +../../../../.config/herbstluftwm/autostart
\ No newline at end of file diff --git a/herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm-panel b/herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm-panel new file mode 120000 index 0000000..4adf4c7 --- /dev/null +++ b/herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm-panel @@ -0,0 +1 @@ +../../../../.config/herbstluftwm/panel.sh
\ No newline at end of file |
