aboutsummaryrefslogtreecommitdiffstats
path: root/herbstluftwm/.local
diff options
context:
space:
mode:
authorPeter Son Struschka <me@peter-struschka.com>2020-08-30 20:56:36 +0800
committerPeter Son Struschka <me@peter-struschka.com>2020-08-30 20:58:04 +0800
commit37dd411698bd6eae8365260dde39b8ae9c7cbd36 (patch)
tree978dd6ea3e72a86e4a3e0314b86d5137fc394785 /herbstluftwm/.local
parenta1d6fc2f3e6ab041cc51cb085ac59a646a126d25 (diff)
downloaddotfiles-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/.local')
-rwxr-xr-xherbstluftwm/.local/bin/q3terminal.sh97
-rwxr-xr-xherbstluftwm/.local/bin/scratchpad.sh70
-rwxr-xr-xherbstluftwm/.local/bin/statusbar/herbstluftwm_tag_list14
l---------herbstluftwm/.local/share/config-files/herbstluftwm-panel1
l---------herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm1
l---------herbstluftwm/.local/share/dotfiles/edit-config.d/herbstluftwm-panel1
6 files changed, 184 insertions, 0 deletions
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