aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar remph <lhr@disroot.org>2024-10-10 18:03:10 +0100
committerLibravatar remph <lhr@disroot.org>2024-10-10 18:07:49 +0100
commit85ca59aea4669ebb9ca46ff62cf2a4248ec61436 (patch)
treee756e4266e9259a0c86c8e66f3745890793b4128
parent3de3d1e46625a272e8e4e529786573dcbed36ceb (diff)
Init a swob/wob.ini if not present, instead of using a temp file. Also,
dwl config.h
-rw-r--r--README.md24
-rw-r--r--dwl-config.h.patch34
-rwxr-xr-xinstall.sh8
-rwxr-xr-xswob.sh11
4 files changed, 64 insertions, 13 deletions
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
+<ul>
+<li>
+Configure your wayland compositor to bind the XF86 volume/brightness
+controls to swob.sh. Example configuration is provided for the following:
+<dl>
+<dt>Sway (options):</dt>
+<dd>Copy the sway config snippet into your own sway config file...</dd>
+<dd><em>Or</em> source it from that file...</dd>
+<dd><em>Or</em> copy it into /etc/sway/config.d</dd>
+<dt>dwl:</dt>
+<dd>An example patch for config.h is available at <a
+href="dwl-config.h.patch">dwl-config.h.patch</a></dd>
+</dl>
+</li>
+<li> Put swob.sh on your PATH, or your wayland compositor's config to point to
+ its exact location. </li>
+</ul>
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 <<EOF
[style.volume]
background_color = 000000
+
[style.mute]
background_color = af0000
+
[style.brightness]
background_color = a89800
EOF
@@ -44,7 +47,7 @@ start_wob() {
# spawn wob process with temporary file(s)
(
- trap 'rm "$wobfifo" ${wobini_istemp:+"$wobini"}' 0
+ trap 'rm "$wobfifo"' 0
# Don't `exec' wob here, else the trap won't work
wob -c "$wobini" -v <$wobfifo
) &