From 85ca59aea4669ebb9ca46ff62cf2a4248ec61436 Mon Sep 17 00:00:00 2001 From: remph Date: Thu, 10 Oct 2024 18:03:10 +0100 Subject: Init a swob/wob.ini if not present, instead of using a temp file. Also, dwl config.h --- README.md | 24 +++++++++++++++++------- dwl-config.h.patch | 34 ++++++++++++++++++++++++++++++++++ install.sh | 8 ++++++-- swob.sh | 11 +++++++---- 4 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 dwl-config.h.patch diff --git a/README.md b/README.md index c26bd7e..e53985d 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,23 @@ Dependencies Installation ------------ -- Put swob.sh on your PATH, or edit the sway(5) config snippet to point to its - exact location. -- Copy the sway config snippet into your own sway config file, or source it - from that file, or copy it into /etc/sway/config.d -- obviously if you - aren't on sway, do the equivalent for your window manager. -- Copy swob-wob.ini to one of: `$XDG_CONFIG_DIR`/swob/wob.ini, - ~/.config/swob/wob.ini, /etc/swob/wob.ini + Copying ------- diff --git a/dwl-config.h.patch b/dwl-config.h.patch new file mode 100644 index 0000000..015fb65 --- /dev/null +++ b/dwl-config.h.patch @@ -0,0 +1,34 @@ +--- a/dwl-v0.5/config.h 2023-11-25 07:15:02.000000000 +0000 ++++ b/dwl-v0.5/config.h 2024-10-07 03:23:12.420734304 +0100 +@@ -114,6 +118,18 @@ + /* commands */ + static const char *termcmd[] = { "foot", NULL }; + static const char *menucmd[] = { "bemenu-run", NULL }; ++ ++static const char ++ swob[] = "swob.sh", ++ swob_up[] = "5%+", ++ swob_down[] = "5%-", ++ swob_vol[] = "volume", ++ swob_brt[] = "brightness", ++ *swob_vol_up[] = { swob, swob_vol, swob_up, NULL }, ++ *swob_vol_down[] = { swob, swob_vol, swob_down, NULL }, ++ *swob_vol_toggle[] = { swob, swob_vol, "toggle", NULL }, ++ *swob_brt_up[] = { swob, swob_brt, swob_up, NULL }, ++ *swob_brt_down[] = { swob, swob_brt, swob_down, NULL }; + + static const Key keys[] = { + /* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */ +@@ -160,6 +180,12 @@ static const Key keys[] = { + #define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} } + CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6), + CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12), ++ ++ { 0, XKB_KEY_XF86MonBrightnessDown, spawn, {.v = swob_brt_down} }, ++ { 0, XKB_KEY_XF86MonBrightnessUp, spawn, {.v = swob_brt_up} }, ++ { 0, XKB_KEY_XF86AudioLowerVolume, spawn, {.v = swob_vol_down} }, ++ { 0, XKB_KEY_XF86AudioRaiseVolume, spawn, {.v = swob_vol_up} }, ++ { 0, XKB_KEY_XF86AudioMute, spawn, {.v = swob_vol_toggle} } + }; + + static const Button buttons[] = { diff --git a/install.sh b/install.sh index 4ea365f..8973287 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,9 @@ #!/bin/sh set -ex -install -m 644 -Dt "$DESTDIR"/etc/sway/config.d/ swob-swayconfig -install -D -m 644 swob-wob.ini "$DESTDIR"/etc/swob/wob.ini +mkdir -p "$DESTDIR"/etc/sway/config.d/ "$DESTDIR"/etc/swob/ +for i in swayconfig wob.ini; do + install -m 644 swob-$i "$DESTDIR"/etc/swob/$i +done +ln -s ../../swob/swayconfig "$DESTDIR"/etc/sway/config.d/swob-swayconfig install -Dt "$DESTDIR"/usr/bin swob.sh +install -m644 -Dt "$DESTDIR"/usr/share/doc/swob README.md dwl-config.h.patch diff --git a/swob.sh b/swob.sh index 222c62b..d0a92b6 100755 --- a/swob.sh +++ b/swob.sh @@ -3,7 +3,7 @@ # SPDX-License-Identifier: FSFULLRWD wobfifo=${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}}/wob -wobini= wobini_istemp= +wobini= readonly wobfifo set -o pipefail -efmu # `set -e' comes after readonly and pipefail, they # aren't vital enough to kill the script for @@ -17,13 +17,16 @@ set_wobini() { done # fallthrough to default: temporary wob.ini(5) standin - echo >&2 "$0: warning: no swob/wob.ini found; defaulting to temporary" - wobini=`mktemp` wobini_istemp=1 + wobini=${XDG_CONFIG_HOME:-~/.config}/swob/wob.ini + echo >&2 "$0: no swob/wob.ini found; writing default to $wobini" + mkdir -p "${wobini%/*}" cat >$wobini <