From e5209aad576fe44d3965fcb94d6709348b0a93bf Mon Sep 17 00:00:00 2001 From: Peter Son Struschka Date: Sun, 11 Oct 2020 12:15:08 +0800 Subject: all: overhaul all: Remove old symlinks herbstluftwm: use polybar instead of dzen2 polybar: update config doom-emacs: update repository --- herbstluftwm/.config/herbstluftwm/autostart | 112 ++++++++++++--------- herbstluftwm/.config/herbstluftwm/bring_sticky.sh | 29 ++++++ .../.config/herbstluftwm/herbstcommander.sh | 88 ++++++++++++++++ herbstluftwm/.config/herbstluftwm/lasttag.sh | 35 +++++++ herbstluftwm/.config/herbstluftwm/panel.sh | 4 +- herbstluftwm/.config/herbstluftwm/polybar.sh | 58 +++++++++++ herbstluftwm/.config/herbstluftwm/rules | 49 +++++++++ herbstluftwm/.config/herbstluftwm/windowmenu.sh | 50 +++++++++ 8 files changed, 374 insertions(+), 51 deletions(-) create mode 100755 herbstluftwm/.config/herbstluftwm/bring_sticky.sh create mode 100755 herbstluftwm/.config/herbstluftwm/herbstcommander.sh create mode 100755 herbstluftwm/.config/herbstluftwm/lasttag.sh create mode 100755 herbstluftwm/.config/herbstluftwm/polybar.sh create mode 100755 herbstluftwm/.config/herbstluftwm/rules create mode 100755 herbstluftwm/.config/herbstluftwm/windowmenu.sh (limited to 'herbstluftwm/.config') diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart index 7605dd2..052f191 100755 --- a/herbstluftwm/.config/herbstluftwm/autostart +++ b/herbstluftwm/.config/herbstluftwm/autostart @@ -2,6 +2,8 @@ # this is a simple config for herbstluftwm +dir="$XDG_CONFIG_HOME/herbstluftwm" + hc() { herbstclient "$@" } @@ -9,9 +11,10 @@ hc() { hc emit_hook reload if hc silent new_attr bool my_not_first_autostart; then - [ ! "$(pidof -x picom)" ] && picom & + [ ! "$(pidof -x picom)" ] && herbstclient spawn picom xset s 600 5 - [ ! "$(pidof -x xss-lock)" ] && xss-lock -n /usr/lib/xsecurelock/dimmer -l -- xsecurelock & + #[ ! "$(pidof -x xss-lock)" ] && xss-lock -n /usr/lib/xsecurelock/dimmer -l -- xsecurelock & + [ ! "$(pidof -x xss-lock)" ] && herbstclient spawn xss-lock -n /usr/lib/xsecurelock/dimmer -l -- slock fi #xsetroot -solid '#5A8E3A' @@ -31,8 +34,8 @@ hc keybind $Mod-Shift-q close hc keybind $Mod-Shift-c close hc keybind $Mod-Return spawn "${TERMINAL:-xterm}" # use your $TERMINAL with xterm as fallback -hc keybind $Mod-x spawn dmenu_run -hc keybind $Mod-d spawn /etc/xdg/herbstluftwm/dmenu_run_hlwm +hc keybind $Mod-x spawn dmenu_run_hlwm +hc keybind $Mod-d spawn rofi -show drun hc keybind $Mod-backslash rotate @@ -84,7 +87,7 @@ 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-$key" and . use_index "$i" . spawn "$dir/bring_sticky.sh" hc keybind "$Mod-Shift-$key" move_index "$i" fi done @@ -93,11 +96,15 @@ 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 +# Previous tag +hc spawn "$dir/lasttag.sh" +hc keybind $Mod-b emit_hook goto_last_tag +hc keybind $Mod-Shift-b emit_hook moveto_last_tag +#hc keybind $Mod-b use_previous # layouting hc keybind $Mod-r remove -hc keybind $Mod-s floating toggle +hc keybind $Mod-Shift-space floating toggle hc keybind $Mod-f fullscreen toggle hc keybind $Mod-Shift-f set_attr clients.focus.floating toggle hc keybind $Mod-p pseudotile toggle @@ -109,13 +116,36 @@ hc keybind $Mod-space . compare tags.focus.curframe_wcount = 2 \ . cycle_layout +1 vertical horizontal max vertical grid \ , cycle_layout +1 +sticky_attr="my_sticky_client" +hc keybind $Mod-s or , set_attr clients.focus."$sticky_attr" toggle \ + , new_attr bool clients.focus."$sticky_attr" true + hc keybind $ModAlt-Tab spawn rofi -show window # scratchpad hc keybind $Mod-grave spawn ~/.local/bin/scratchpad.sh -# media +# hidden +hidden_tag="hidden" +hc add "$hidden_tag" +# hide window +hc keybind $Mod-t move "$hidden_tag" +# bring all hidden windows to current tag +hc keybind $Mod-Shift-t \ + foreach T clients. \ + sprintf S "%c.tag" T \ + and . compare S "=" "$hidden_tag" \ + . sprintf IDATTR "%c.winid" T \ + sprintf ID "%s" IDATTR \ + bring ID + +hc keybind $Mod-m spawn "$dir/windowmenu.sh" +hc keybind $Mod-n spawn hlwm_goto_tag + +hc keybind $Mod-w spawn "$dir/herbstcommander.sh" + +# XF86 keys hc keybind XF86AudioLowerVolume spawn change-vol - hc keybind XF86AudioRaiseVolume spawn change-vol + hc keybind XF86AudioMute spawn pactl set-sink-mute 0 toggle @@ -128,6 +158,7 @@ hc keybind XF86AudioPrev spawn playerctl previous hc keybind XF86MonBrightnessDown spawn brightnessctl s "5%-" hc keybind XF86MonBrightnessUp spawn brightnessctl s "+5%" +# lock hc keybind $Mod-Shift-Delete spawn xset s activate # mouse @@ -154,16 +185,6 @@ hc keybind $Mod-i jumpto urgent # 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 1 -hc set always_show_frame on -hc set frame_bg_transparent on -hc set frame_transparent_width 5 -hc set frame_gap 4 - hc attr theme.active.color '#9fbc00' hc attr theme.normal.color '#454545' hc attr theme.urgent.color orange @@ -177,33 +198,33 @@ hc attr theme.active.inner_color '#3E4A00' hc attr theme.active.outer_color '#3E4A00' hc attr theme.background_color '#141414' -hc set window_gap 2 +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 1 +hc set always_show_frame off +hc set frame_bg_transparent on +hc set frame_transparent_width 5 +hc set frame_gap 4 +hc set window_gap 0 hc set frame_padding 0 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 -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)' floating=on -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 hide_covered_windows off +hc set focus_crosses_monitor_boundaries on +hc set swap_monitors_to_get_tag on +hc set focus_stealing_prevention off +hc set focus_follows_mouse true hc set tree_style '╾│ ├└╼─┐' +# rules +rules="$XDG_CONFIG_HOME/herbstluftwm/rules" +[ -x "$rules" ] && source "$rules" + # unlock, just to be sure hc unlock @@ -212,16 +233,7 @@ hc unlock # or simply: hc detect_monitors -# find the panel -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 - 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" +# restartpanels +"$dir/polybar.sh" hlwm +#restartpanels.sh + diff --git a/herbstluftwm/.config/herbstluftwm/bring_sticky.sh b/herbstluftwm/.config/herbstluftwm/bring_sticky.sh new file mode 100755 index 0000000..d0f1250 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/bring_sticky.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Script to bring non visible sticky windows over +# to the current tag + +hc() { + herbstclient "$@" +} + +hc lock + +read -ra other_monitor <<< "$(hc tag_status | tr '\t' '\n' | sed -n 's/-//p')" +declare -A other_monitor_map +for key in "${!other_monitor[@]}"; do other_monitor_map[${other_monitor[$key]}]="$key"; done + +win_ids=$(hc foreach T clients. \ + sprintf S "%c.my_sticky_client" T \ + and . silent compare S "=" "true" \ + . sprintf WINIDATTR "%c.winid" T \ + attr WINIDATTR 2>&1) +win_array=($win_ids) + +for sticky_winid in "${win_array[@]}"; do + tag=$(hc attr "clients.$sticky_winid.tag") + if [ ! ${other_monitor_map[$tag]+_} ]; then hc bring "$sticky_winid"; fi +done + +hc unlock + diff --git a/herbstluftwm/.config/herbstluftwm/herbstcommander.sh b/herbstluftwm/.config/herbstluftwm/herbstcommander.sh new file mode 100755 index 0000000..efe5f20 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/herbstcommander.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +# herbstcommander.sh - launch herbstluftwm-commands via dmenu +# Written by Florian Bruhin + +# To customize dmenu-colors, create a file named "herbstcommander" in your +# herbstluftwm config-directory, with something like this in it: +# +# dmenu_command=(dmenu -i -b -nb '#313131' -nf '#686868' -sb '#454545' -sf '#898989') +# +# You can also directly pass dmenu-arguments to this script instead, as long +# as dmenu_command is undefined. + +config_1="$XDG_CONFIG_HOME/herbstluftwm/herbstcommander" +config_2="$HOME/.config/herbstluftwm/herbstcommander" +[[ -f "$config_1" ]] && source "$config_1" +[[ -f "$config_2" ]] && source "$config_2" + +dm() { + if [[ "${dmenu_command[@]}" ]]; then + "${dmenu_command[@]}" "$@" + else + dmenu -i "$@" + fi +} + +hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;} +prompt=${prompt:-herbstluft: } +display_reply=${display_reply:-true} + +cmd=( "$@" ) +forceexec=0 + +while :; do + dmenu_args="" + if [[ "$forceexec" != 1 ]]; then + completion=$(hc complete "${#cmd[@]}" "${cmd[@]}") + if [[ "$?" = 7 ]] ; then + forceexec=1 + fi + fi + if [[ "$forceexec" == 1 ]]; then + echo "Executing ${cmd[@]}" + reply=$(hc "${cmd[@]}") + status=$? + if [[ "$display_reply" && "$reply" ]]; then + dm -p "${cmd[*]}" <<< "$reply" >/dev/null + fi + exit $status + else + case "${cmd[*]}" in + raise|jumpto|bring) + IFS=$'\t' read -ra tags <<< "$(hc tag_status)" + i=1 + completion=$( + wmctrl -l | while read line; do + IFS=' ' read -ra fields <<< "$line" + id=${fields[0]} + tag=${tags[ ${fields[1]} ]} + class=$(xprop -notype -id $id WM_CLASS | + sed 's/.*\?= *//; s/"\(.*\?\)", *"\(.*\?\)".*/\1,\2/') + title=${fields[@]:3} + printf "%-3s %s %-3s [%s] %s\n" "$i)" "$id" "$tag" "$class" "$title" + i=$((i+1)) + done + ) + + dmenu_args="-l 10" + ;; + esac + next=$(dm $dmenu_args -p "${prompt}${cmd[*]}" <<< "$completion") + (( $? != 0 )) && exit 125 # dmenu was killed + if [[ -z "$next" ]]; then + forceexec=1 # empty reply instead of completion + else + case "${cmd[*]}" in + raise|jumpto|bring) + # add the WINID only (second field) + IFS=' ' read -ra fields <<< "$next" + cmd+=( ${fields[1]} ) + ;; + *) + cmd+=( $next ) + ;; + esac + fi + fi +done diff --git a/herbstluftwm/.config/herbstluftwm/lasttag.sh b/herbstluftwm/.config/herbstluftwm/lasttag.sh new file mode 100755 index 0000000..d4c328c --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/lasttag.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# usage: start this script in anywhere your autostart (but *after* the +# emit_hook reload line) + +# to switch to the last tag, call: herbstclient emit_hook goto_last_tag +# or bind it: herbstclient keybind Mod1-Escape emit_hook goto_last_tag + + +dir="$XDG_CONFIG_HOME/herbstluftwm" + +hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;} + +tag="$(hc attr tags.focus.name)" +lasttag="$tag" + +hc --idle '(tag_changed|goto_last_tag|reload)' \ + | while read line ; do + IFS=$'\t' read -ra args <<< "$line" + case ${args[0]} in + tag_changed) + lasttag="$tag" + tag=${args[1]} + ;; + goto_last_tag) + [ "$lasttag" ] && hc and . use "$lasttag" . spawn "$dir/bring_sticky.sh" + ;; + moveto_last_tag) + [ "$lasttag" ] && hc and . move "$lasttag" . spawn "$dir/bring_sticky.sh" + ;; + reload) + exit + ;; + esac + done diff --git a/herbstluftwm/.config/herbstluftwm/panel.sh b/herbstluftwm/.config/herbstluftwm/panel.sh index ebdd59a..229e31e 100755 --- a/herbstluftwm/.config/herbstluftwm/panel.sh +++ b/herbstluftwm/.config/herbstluftwm/panel.sh @@ -128,6 +128,8 @@ hc pad $monitor $panel_height for i in "${tags[@]}" ; do # don't render these hidden tags case ${i:1} in + 'hidden') + ;& 'scratchpad') continue ;; esac @@ -185,7 +187,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 diff --git a/herbstluftwm/.config/herbstluftwm/polybar.sh b/herbstluftwm/.config/herbstluftwm/polybar.sh new file mode 100755 index 0000000..01d3d91 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/polybar.sh @@ -0,0 +1,58 @@ +#!/bin/env bash + +killall -q polybar + +while pgrep -u $UID -x polybar >/dev/null; do + sleep 0.5 +done + +hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;} + +# manually set padding +hc set auto_detect_panels false + +monitor_bound() { + echo "$1" | cut -d' ' -f2 +} + +name() { + echo "$1" | sed -e 's/:.*$//g' +} + +hlwm_id() { + while read -r bound; do + hc list_monitors | grep "$bound" | sed -e 's/:.*$//g' + done <<< "$(monitor_bound "$1")" +} + +primary_mon=$(polybar -m | grep '(primary)') +primary_mon_name=$(name "$primary_mon") +all_monitors=$(polybar -m | + sed -e 's/:.*$//g') +for name in $all_monitors; do + declare "${name}_height=16" +done + +wm=${1:+"-$1"} + +# +MONITOR=$(name "$primary_mon_name") polybar "topbar${wm}" & +primary_height_var="${primary_mon_name}_height" +declare "${primary_mon_name}_height=$((${!primary_height_var}+16))" + +while read -r mon; do + echo "launching bar on $(name "$mon")" + height_var="$(name "$mon")_height" + echo "${height_var}" + echo "${!height_var}" + OFFSET_Y="$((${!height_var}-16))" MONITOR="$(name "$mon")" polybar "topbar2${wm}" & + #sleep 2 + echo -n "name: " + name "$mon" + echo + echo -n "id hlwm: " + hlwm_id "$mon" + hc pad "$(hlwm_id "$mon")" "${!height_var}" +done <<< "$(polybar -m)" + +echo "Bars launched" diff --git a/herbstluftwm/.config/herbstluftwm/rules b/herbstluftwm/.config/herbstluftwm/rules new file mode 100755 index 0000000..9fedcae --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/rules @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +hc() { + herbstclient "$@" +} + +# 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)' \ + floating=on +hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' \ + focus=on +hc rule windowrole='pop-up' \ + floating=on +hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' \ + manage=off + +# use xprop with mouse or +# DISPLAY=:0 xprop -name "..." +# xprop to rule conditions +# WM_CLASS(STRING) = "", "" +# WM_NAME(STRING) = "" +# _NET_WM_WINDOW_TYPE_(ATOM) = <windowtype> +# WM_WINDOW_ROLE(STRING) = "<windowrole>" +hc rule class='jetbrains-toolbox' \ + floating=on floatplacement=none focus=off +hc rule instance~'jetbrains-[a-z]*' class~'jetbrains-[a-z]*' title='win0' \ + floating=on floatplacement=center focus=off +hc rule instance~'jetbrains-[a-z]*' class~'jetbrains-[a-z]*' \ + title='Cannot execute command' \ + floating=on floatplacement=center focus=off +hc rule instance~'jetbrains-[a-z]*' class~'jetbrains-[a-z]*' \ + title~'(Welcome.*)|(Java)' \ + floating=on floatplacement=center focus=off +hc rule instance='gcr-prompter' class='Gcr-prompter' title='Unlock Keyring' \ + floating=on floatplacement=center focus=off +hc rule instance=Steam class=Steam title~'Steam( .*)' \ + focus=off +hc rule instance=Steam class=Steam title~'(.*)List(.*)' \ + focus=off +hc rule instance=scratchpad \ + tag=scratchpad + diff --git a/herbstluftwm/.config/herbstluftwm/windowmenu.sh b/herbstluftwm/.config/herbstluftwm/windowmenu.sh new file mode 100755 index 0000000..9de0f46 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/windowmenu.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +set -e +# +# dependencies: +# +# - rofi + +# offer a window menu offering possible actions on that window like +# moving to a different tag or toggling its fullscreen state + +action_list() { + local a="$1" + "$a" "Close" herbstclient close + "$a" "Toggle fullscreen" herbstclient fullscreen toggle + "$a" "Toggle pseudotile" herbstclient pseudotile toggle + for tag in $(herbstclient complete 1 move) ; do + "$a" "Move to tag $tag" herbstclient move "$tag" + done +} + +print_menu() { + echo "$1" +} + +title=$(herbstclient attr clients.focus.title) +title=${title//&/&} +rofiflags=( + -p "herbstclient:" + -mesg "<i>$title</i>" + -columns 3 + -location 2 + -width 100 + #-no-custom +) +result=$(action_list print_menu | rofi -i -dmenu -m -2 "${rofiflags[@]}") +[ $? -ne 0 ] && exit 0 + +exec_entry() { + if [ "$1" = "$result" ] ; then + shift + "$@" + exit 0 + else + herbstclient add "$result" + herbstclient move "$result" + fi +} + +action_list exec_entry + -- cgit v1.2.3