From 37dd411698bd6eae8365260dde39b8ae9c7cbd36 Mon Sep 17 00:00:00 2001 From: Peter Son Struschka Date: Sun, 30 Aug 2020 20:56:36 +0800 Subject: all: overhaul, move dotfile specifics to .local/share/dotfiles and more --- herbstluftwm/.config/herbstluftwm/autostart | 35 +++++++++++-- herbstluftwm/.config/herbstluftwm/panel.sh | 77 +++++++++++++++++++++++++---- 2 files changed, 100 insertions(+), 12 deletions(-) (limited to 'herbstluftwm/.config') 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 -- cgit v1.2.3