From 3de3d1e46625a272e8e4e529786573dcbed36ceb Mon Sep 17 00:00:00 2001 From: remph Date: Wed, 25 Sep 2024 20:02:25 +0100 Subject: Separate wob.ini(5); add PKGBUILD --- PKGBUILD | 24 ++++++++++++++++++++++++ README.md | 17 ++++++++++------- install.sh | 5 +++++ swob-wob.ini | 8 ++++++++ swob.sh | 53 ++++++++++++++++++++++++++--------------------------- 5 files changed, 73 insertions(+), 34 deletions(-) create mode 100644 PKGBUILD create mode 100755 install.sh create mode 100644 swob-wob.ini diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..b90a172 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,24 @@ +pkgname=swob-git +pkgver=0 +pkgrel=1 +pkgdesc='Volume and brightness controls for wayland, using wob' +arch=(any) # limited only by dependencies +depends=(sh coreutils sed wob alsa-utils brightnessctl) +url='https://github.com/el-remph/swob' +license=(FSFULLRWD) +provides=(swob) +source=("git+$url") +b2sums=(SKIP) + +pkgver() ( + cd swob + set -o pipefail + git describe --long --abbrev=7 --tags 2>/dev/null | + sed -e 's/^v//' -e 's/[^-]*-g/r&/' -e y/-/./ || + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)" +) + +package() { + cd swob + DESTDIR=$pkgdir ./install.sh +} diff --git a/README.md b/README.md index 8c0617d..c26bd7e 100644 --- a/README.md +++ b/README.md @@ -28,19 +28,22 @@ 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. +- 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 ------- Copyright © 2024 The Remph -This file is free software; the Remph gives unlimited permission to copy -and/or distribute it, with or without modification, as long as this -notice is preserved. +These files are free software; the Remph gives unlimited permission to copy +and/or distribute them, with or without modification, as long as this notice +is preserved. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..4ea365f --- /dev/null +++ b/install.sh @@ -0,0 +1,5 @@ +#!/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 +install -Dt "$DESTDIR"/usr/bin swob.sh diff --git a/swob-wob.ini b/swob-wob.ini new file mode 100644 index 0000000..a3a37b8 --- /dev/null +++ b/swob-wob.ini @@ -0,0 +1,8 @@ +[style.volume] +background_color = 000000 + +[style.mute] +background_color = af0000 + +[style.brightness] +background_color = a89800 diff --git a/swob.sh b/swob.sh index 6a62adf..222c62b 100755 --- a/swob.sh +++ b/swob.sh @@ -3,49 +3,48 @@ # SPDX-License-Identifier: FSFULLRWD wobfifo=${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}}/wob +wobini= wobini_istemp= readonly wobfifo -set -o pipefail -e # `set -e' comes after readonly and pipefail, they +set -o pipefail -efmu # `set -e' comes after readonly and pipefail, they # aren't vital enough to kill the script for -start_wob() { - if test -e "$wobfifo"; then - return # Already started - fi - - # temporary fifo (call mkfifo(1) asap to minimise possibility of races) - # TODO: should this be in C, so we can call mkfifo(2) and check for - # EEXIST, rather than using test(1)? Alternatively, there is flock(1), - # or any other IPC or SHM system - mkfifo -m600 "$wobfifo" - - default_wobini= +set_wobini() { for dir in ${XDG_CONFIG_HOME:+"$XDG_CONFIG_HOME"} ~/.config /etc; do - if test -r "$dir"/wob/wob.ini; then - default_wobini="$dir"/wob/wob.ini - break + if test -r "$dir"/swob/wob.ini; then + wobini="$dir"/swob/wob.ini + return fi done - # temporary wob.ini(5) file, to set wob colours - wobini=`mktemp` - { - # This order means that a user can change the styles in - # their own config if they like - printf '[style.mute]\nbackground_color = af0000\n\n' - cat - ${default_wobini:+"$default_wobini"} <&2 "$0: warning: no swob/wob.ini found; defaulting to temporary" + wobini=`mktemp` wobini_istemp=1 + cat >$wobini <$wobini +} + +start_wob() { + if test -e "$wobfifo"; then + return # Already started + fi + + # temporary fifo (call mkfifo(1) asap to minimise possibility of races) + # TODO: should this be in C, so we can call mkfifo(2) and check for + # EEXIST, rather than using test(1)? Alternatively, there is flock(1), + # or any other IPC or SHM system + mkfifo -m600 "$wobfifo" + + set_wobini - # spawn wob process with temporary files + # spawn wob process with temporary file(s) ( - trap 'rm "$wobini" "$wobfifo"' 0 + trap 'rm "$wobfifo" ${wobini_istemp:+"$wobini"}' 0 # Don't `exec' wob here, else the trap won't work wob -c "$wobini" -v <$wobfifo ) & -- cgit