aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-04-28 17:34:08 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-04-28 17:34:08 +0200
commit2477463f29bb430b5948a3de636f619608ea720b (patch)
tree9eaab6f68033a3a63b2a12f2e298d85a012792a2
parent61c12be3c7c0c22b4feb63ac4b5acfcfd252b7d5 (diff)
Update hlwm for use within KDE
-rwxr-xr-x.config/herbstluftwm/autostart70
-rwxr-xr-x.config/herbstluftwm/panel-bot.sh86
-rwxr-xr-x.config/herbstluftwm/panel-top.sh194
3 files changed, 24 insertions, 326 deletions
diff --git a/.config/herbstluftwm/autostart b/.config/herbstluftwm/autostart
index 5bcf1d8..df3eb3b 100755
--- a/.config/herbstluftwm/autostart
+++ b/.config/herbstluftwm/autostart
@@ -17,7 +17,7 @@ hc keyunbind --all
Mod=Mod4 # Use the super key as the main modifier
hc keybind $Mod-Shift-x quit
-hc keybind $Mod-r reload
+hc keybind $Mod-Shift-r reload
hc keybind $Mod-x close
# basic movement in tiling and floating mode
@@ -48,8 +48,8 @@ hc keybind $Mod-Alt-k resize up +$resizestep
hc keybind $Mod-Alt-l resize right +$resizestep
# tags
-tag_names=( work social web mail fun media vms 8 9 )
-tag_keys=( {2..9} 0 )
+tag_names=( work social web mail fun media vms scratch )
+tag_keys=( {2..9} )
hc rename default "${tag_names[0]}" || true
for i in "${!tag_names[@]}" ; do
@@ -88,8 +88,8 @@ hc mousebind $Mod-Button3 resize
# focus
hc set focus_follows_mouse 1
-hc keybind $Mod-Control+j cycle_monitor -1
-hc keybind $Mod-Control+k cycle_monitor +1
+hc keybind $Mod-Control+j cycle_monitor +1
+hc keybind $Mod-Control+k cycle_monitor -1
hc keybind $Mod-Tab cycle_all +1
hc keybind $Mod-Shift-Tab cycle_all -1
hc keybind $Mod-c cycle
@@ -131,18 +131,31 @@ hc set mouse_recenter_gap 0
# 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 floatplacement=smart
-#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
+
+# Tag rules
+hc rule class='signal' tag=social
+hc rule class='mumble' tag=social
+
+hc rule class='qutebrowser' tag=www
+hc rule class='chromium' tag=www
+
+hc rule class='thunderbird' tag=mail
+
+hc rule class='mpv' tag=media
+
+# KDE rules
+hc rule class='krunner' floating=on floatplacement=center
+hc rule class='plasmashell' floating=on
+
+# Regular rules
+hc rule class='pinentry' floating=on floatplacement=center
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="wow.exe" tag=5 floating=on
-
hc set tree_style '╾│ ├└╼─┐'
# unlock, just to be sure
@@ -152,38 +165,3 @@ hc unlock
# hc set_monitors 1280x1024+0+0 1280x1024+1280+0
# or simply:
hc detect_monitors
-
-# Handle panels
-panel_top=~/.config/herbstluftwm/panel-top.sh
-[ -x "$panel_top" ] || panel_top=/etc/xdg/herbstluftwm/panel.sh
-
-panel_bot=~/.config/herbstluftwm/panel-bot.sh
-
-for monitor in $(hc list_monitors | cut -d: -f1) ; do
- # Create space for the panels to exist
- hc pad "$monitor" 21 0 21 0
-
- # Start panels
- "$panel_top" "$monitor" &
- "$panel_bot" "$monitor" &
-done
-
-# Handle tray
-if command -v stalonetray > /dev/null
-then
- tray_monitor_offset=$(hc monitor_rect 0 | awk '{ print $1 }')
- tray_monitor_width=$(hc monitor_rect 0 | awk '{ print $3 }')
- tray_date_offset=$(xftwidth "Liberation Mono:size=9" "$(date +"%F %H:%M")")
- tray_offset_x=$(( tray_monitor_offset + tray_monitor_width - tray_date_offset - 40 ))
-
- stalonetray \
- --grow-gravity E \
- --icon-size 16 \
- --parent-bg \
- --config /dev/null \
- --skip-taskbar \
- --sticky \
- --geometry "1x1+$tray_offset_x+2" \
- --kludges fix_window_pos \
- &
-fi
diff --git a/.config/herbstluftwm/panel-bot.sh b/.config/herbstluftwm/panel-bot.sh
deleted file mode 100755
index a42ea1e..0000000
--- a/.config/herbstluftwm/panel-bot.sh
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env bash
-
-hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ; }
-quote() { local q="$(printf '%q ' "$@")"; printf '%s' "${q% }" ; }
-uniq_linebuffered() { awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"; }
-
-monitor=${1:-0}
-
-hc attr "monitors.$monitor" > /dev/null || { printf "Invalid monitor $monitor" && exit 1 ; }
-
-monitor_offset_x=$(hc monitor_rect "$monitor" | awk '{print $1 }')
-monitor_offset_y=$(hc monitor_rect "$monitor" | awk '{print $2 }')
-monitor_width=$(hc monitor_rect "$monitor" | awk '{ print $3 }')
-monitor_height=$(hc monitor_rect "$monitor" | awk '{ print $4 }')
-panel_height=21
-panel_color_bg="$(hc get frame_border_normal_color)"
-panel_color_fg="#efefef"
-panel_color_focus="$(hc get frame_border_active_color)"
-panel_font="Liberation Mono:size=9"
-panel_offset_x=$(( monitor_offset_x ))
-panel_offset_y=$(( monitor_offset_y + monitor_height - panel_height ))
-
-{
- hc --idle
-} 2> /dev/null | {
- while :
- do
- # Wait for an event
- IFS=$'\t' read -ra event || break
-
- # Declare clients as an array
- declare -a clients
-
- # Check which tag the monitor is on now
- monitor_tag="$(herbstclient attr "monitors.$monitor.tag")"
-
- # Collect all clients on the monitor
- for client in $(hc attr clients | grep '0x')
- do
- [[ "$(hc attr "clients.$client.tag")" != $monitor_tag ]] && continue
-
- clients+=("$client")
- done
-
- name_offset_interval=$(( monitor_width / ${#clients[@]} ))
-
- # Look up current focus window
- focus="$(hc attr clients.focus.winid)"
-
- # Loop through the clients to create a representation
- index=0
-
- for client in "${clients[@]}"
- do
-
- if [[ "$client" == "$focus." ]]
- then
- color_fg="$panel_color_focus"
- else
- color_fg="$panel_color_fg"
- fi
-
- name=" $(hc attr "clients.$client.title") "
- name_width=$(xftwidth "$panel_font" "$name")
- name_offset=$(( name_offset_interval * index ))
-
- printf "^pa(%s)^bg(%s)^fg(%s)^ca(1,%s)%s^ca()" \
- "$name_offset" \
- "$panel_color_bg" \
- "$color_fg" \
- "herbstclient jumpto '$client'" \
- "$name"
-
- index=$(( index + 1 ))
- done
-
- # Add a newline
- printf "\n"
-
- # Clean up some variables
- unset clients
- unset index
- done
-} | dzen2 -w "$monitor_width" -x "$panel_offset_x" -y "$panel_offset_y" -fn "$panel_font" -h "$panel_height" \
- -e "button3=;button4=exec:$hc_quoted use_index -1;button5=exec:$hc_quoted use_index +1" \
- -ta l -bg "$panel_color_bg" -fg "$panel_color_fg"
diff --git a/.config/herbstluftwm/panel-top.sh b/.config/herbstluftwm/panel-top.sh
deleted file mode 100755
index c0ea7e6..0000000
--- a/.config/herbstluftwm/panel-top.sh
+++ /dev/null
@@ -1,194 +0,0 @@
-#!/usr/bin/env bash
-
-quote() {
- local q="$(printf '%q ' "$@")"
- printf '%s' "${q% }"
-}
-
-hc_quoted="$(quote "${herbstclient_command[@]:-herbstclient}")"
-hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;}
-monitor=${1:-0}
-geometry=( $(hc monitor_rect "$monitor") )
-if [ -z "$geometry" ] ;then
- echo "Invalid monitor $monitor"
- exit 1
-fi
-# geometry has the format W H X Y
-x=${geometry[0]}
-y=${geometry[1]}
-panel_width=${geometry[2]}
-panel_height=21
-font="Liberation Mono:size=9"
-bgcolor=$(hc get frame_border_normal_color)
-selbg=$(hc get window_border_active_color)
-selfg='#101010'
-
-####
-# Try to find textwidth binary.
-# In e.g. Ubuntu, this is named dzen2-textwidth.
-if which xftwidth > /dev/null
-then
- textwidth=xftwidth
-elif which textwidth > /dev/null
-then
- textwidth="textwidth";
-else
- echo "This script requires the textwidth tool of the dzen2 project."
- exit 1
-fi
-
-####
-# true if we are using the svn version of dzen2
-# depending on version/distribution, this seems to have version strings like
-# "dzen-" or "dzen-x.x.x-svn"
-if dzen2 -v 2>&1 | head -n 1 | grep -q '^dzen-\([^,]*-svn\|\),'; then
- dzen2_svn="true"
-else
- dzen2_svn=""
-fi
-
-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 ###
- # based on different input data (mpc, date, hlwm hooks, ...) this generates events, formed like this:
- # <eventname>\t<data> [...]
- # e.g.
- # date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
-
- #mpc idleloop player &
- while true ; do
- # "date" output is checked once a second, but an event is only
- # generated if the output changed compared to the previous run.
- date +$'date\t^fg(#909090)%F ^fg(#efefef)%H:%M'
- 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=""
- windowtitle=""
- while true ; do
-
- ### Output ###
- # This part prints dzen data based on the _previous_ data handling run,
- # and then waits for the next event to happen.
-
- separator="^bg()^fg($selbg)|"
- # draw tags
- for i in "${tags[@]}" ; do
- case ${i:0:1} in
- '#')
- echo -n "^bg($selbg)^fg($selfg)"
- ;;
- '-')
- echo -n "^bg()^fg(#9CA668)"
- ;;
- '+')
- echo -n "^bg(#9CA668)^fg(#141414)"
- ;;
- '%')
- echo -n "^bg()^fg($selbg)"
- ;;
- ':')
- echo -n "^bg()^fg(#ffffff)"
- ;;
- '!')
- echo -n "^bg(#FF0675)^fg(#141414)"
- ;;
- *)
- echo -n "^bg()^fg(#ababab)"
- ;;
- esac
- if [ ! -z "$dzen2_svn" ] ; then
- # clickable tags if using SVN dzen
- echo -n "^ca(1,$hc_quoted focus_monitor \"$monitor\" && "
- echo -n "$hc_quoted use \"${i:1}\") ${i:1} ^ca()"
- else
- # non-clickable tags if using older dzen
- echo -n " ${i:1} "
- fi
- done
- echo -n "$separator"
- echo -n "^bg()^fg() ${windowtitle//^/^^}"
- # small adjustments
- right="$separator^bg() $date"
- 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 ")
- echo -n "^pa($(($panel_width - $width)))$right"
- echo
-
- ### Data handling ###
- # This part handles the events generated in the event loop, and sets
- # internal variables based on them. The event and its arguments are
- # read into the array cmd, then action is taken depending on the event
- # name.
- # "Special" events (quit_panel/togglehidepanel/reload) are also handled
- # here.
-
- # wait for next event
- IFS=$'\t' read -ra cmd || break
- # find out event origin
- case "${cmd[0]}" in
- tag*)
- #echo "resetting tags" >&2
- IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
- ;;
- date)
- #echo "resetting date" >&2
- date="${cmd[@]:1}"
- ;;
- quit_panel)
- exit
- ;;
- togglehidepanel)
- currentmonidx=$(hc list_monitors | sed -n '/\[FOCUS\]$/s/:.*//p')
- if [ "${cmd[1]}" -ne "$monitor" ] ; then
- continue
- fi
- if [ "${cmd[1]}" = "current" ] && [ "$currentmonidx" -ne "$monitor" ] ; then
- continue
- fi
- echo "^togglehide()"
- if $visible ; then
- visible=false
- hc pad $monitor 0
- else
- visible=true
- hc pad $monitor $panel_height
- fi
- ;;
- reload)
- exit
- ;;
- focus_changed|window_title_changed)
- windowtitle="${cmd[@]:2}"
- ;;
- #player)
- # ;;
- esac
- done
-
- ### dzen2 ###
- # After the data is gathered and processed, the output of the previous block
- # gets piped to dzen2.
-
-} | 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" \
- -ta l -bg "$bgcolor" -fg '#efefef'