commit 84b63f3a24690c944b689ccab20bc63f46d95052
parent b26879d6e23281975380503f1b8075a9ca0f9ad0
Author: pyratebeard <root@pyratebeard.net>
Date: Tue, 5 Jul 2022 17:13:05 +0100
tweaking
add min_max script and keybind for screenlock. focus new frame on split. add tag names and set tags to specific monitors
Diffstat:
2 files changed, 110 insertions(+), 6 deletions(-)
diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart
@@ -28,9 +28,15 @@ echo 35 > /tmp/herbstluftwm-gap
Mod=Mod4
Alt=Mod1
+# minimize and unminimise windows
+bash /home/pyratebeard/bin/herbstluftwm-min_max
+
# run menu
hc keybind $Mod-w spawn /usr/bin/zsh /home/pyratebeard/bin/rundmc
+# lock screen
+hc keybind $Mod-z spawn bash /home/pyratebeard/bin/lock
+
# dynamic window gap
hc keybind $Mod-9 spawn bash /home/pyratebeard/bin/herbstluftwm-remove-gap
hc keybind $Mod-0 spawn bash /home/pyratebeard/bin/herbstluftwm-add-gap
@@ -64,8 +70,8 @@ hc keybind $Mod-Shift-l shift right
# splitting frames
# create an empty frame at the specified direction
-hc keybind $Mod-u split bottom 0.5 #row
-hc keybind $Mod-o split right 0.5 #column
+hc keybind $Mod-u chain , split bottom 0.5 , focus down #row
+hc keybind $Mod-o chain , split right 0.5 , focus right #column
# let the current frame explode into subframes
hc keybind $Mod-Control-space split explode
@@ -82,8 +88,8 @@ hc keybind $Mod-Control-Right resize right +$resizestep
# tags
-#tag_names=( 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 )
-tag_names=( {0..3} )
+tag_names=( ~ web grind drudge )
+#tag_names=( {0..3} )
tag_keys=( {1..4} 0 )
# set up normal tags
@@ -92,11 +98,36 @@ 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" \
+ chain , silent substitute M tags."$i".my_monitor \
+ focus_monitor M \
+ , use_index "$i"
hc keybind "$Mod-Shift-$key" move_index "$i"
fi
done
+hc keybind $Mod-t chain \
+ , new_attr string tags.focus.my_monitor \
+ , substitute M monitors.focus.indix set_attr tags.focus.my_monitor M \
+ , try and \
+ . compare monitors.focus.name != "" \
+ . substitute M monitors.focus.name \
+ set_attr tags.focus.my_monitor M
+
+hc keybind $Mod-Shift-t \
+ remove_attr tags.focus.my_monitor
+
+lock_tag_to_monitor() {
+ hc chain \
+ , new_attr string tags.by-name."$1".my_monitor \
+ , set_attr tags.by-name."$1".my_monitor "$2"
+}
+
+lock_tag_to_monitor 0 0
+lock_tag_to_monitor 1 1
+lock_tag_to_monitor 2 0
+lock_tag_to_monitor 3 1
+
# cycle through tags
hc keybind $Mod-$Alt-Left use_index -1 --skip-visible
hc keybind $Mod-$Alt-Right use_index +1 --skip-visible
@@ -105,7 +136,7 @@ hc keybind $Mod-$Alt-Right use_index +1 --skip-visible
hc keybind $Mod-x remove
hc keybind $Mod-space cycle_layout 1
hc keybind $Mod-Shift-space cycle_layout -1
-#hc keybind $Mod-s floating toggle
+hc keybind $Mod-s set_attr clients.focus.floating toggle
hc keybind $Mod-f fullscreen toggle
hc keybind $Mod-p pseudotile toggle
diff --git a/herbstluftwm/bin/herbstluftwm-min_max b/herbstluftwm/bin/herbstluftwm-min_max
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+
+# A script allowing to minimize and un-minimize clients in a LIFO way
+# (last minimized client will be un-minimized first).
+#
+# `chmod +x unminimize.sh` then call it or add it to `autostart`.
+
+
+Mod=${Mod:-Mod4}
+Minimizekey=Shift-m
+Unminimizekey=Ctrl-m
+# get the absolute path of this script, to call it when minimizing
+SCRIPT_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/$(basename "${BASH_SOURCE[0]}")
+
+hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;}
+
+
+#
+# initialize minimize and unminimize shortcuts
+#
+init() {
+
+ # initialize a global minimization counter
+ hc silent new_attr uint my_minimized_counter 1
+
+ # minimize current window
+ hc keybind $Mod-$Minimizekey spawn "$SCRIPT_PATH" minimize
+
+ # unminimize last window of a tag
+ # if the `my_minimized_age` attribute does not exist (i.e. the window has not been
+ # minimized with this script), use arbitrary order to unminimize
+ hc keybind $Mod-$Unminimizekey mktemp string LASTCLIENTATT mktemp uint LASTAGEATT chain \
+ . set_attr LASTAGEATT 0 \
+ . foreach CLIENT clients. and \
+ , sprintf MINATT "%c.minimized" CLIENT \
+ compare MINATT "=" "true" \
+ , sprintf TAGATT "%c.tag" CLIENT substitute FOCUS "tags.focus.name" \
+ compare TAGATT "=" FOCUS \
+ , sprintf AGEATT "%c.my_minimized_age" CLIENT or \
+ case: and \
+ : ! get_attr AGEATT \
+ : compare LASTAGEATT "=" 0 \
+ case: and \
+ : substitute LASTAGE LASTAGEATT \
+ compare AGEATT 'gt' LASTAGE \
+ : substitute AGE AGEATT \
+ set_attr LASTAGEATT AGE \
+ , set_attr LASTCLIENTATT CLIENT \
+ . and \
+ , compare LASTCLIENTATT "!=" "" \
+ , substitute CLIENT LASTCLIENTATT chain \
+ : sprintf MINATT "%c.minimized" CLIENT \
+ set_attr MINATT false \
+ : sprintf AGEATT "%c.my_minimized_age" CLIENT \
+ try remove_attr AGEATT \
+
+}
+
+
+#
+# minimize focused client
+#
+minimize() {
+
+ hc and \
+ . substitute C my_minimized_counter new_attr uint clients.focus.my_minimized_age C \
+ . set_attr my_minimized_counter $(($(hc get_attr my_minimized_counter)+1)) \
+ . set_attr clients.focus.minimized true \
+
+}
+
+
+if [ "$1" = "minimize" ] ; then minimize ; else init ; fi