dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit a62afdfe323fc3e5f0249f032d82a94887004459
parent 2a5662ee542b1674bd828bfc51a97d6fe6a9686c
Author: Chris Bracken <chris@bracken.jp>
Date:   Tue, 17 Oct 2023 00:36:21 -0700

i3/sway: consistency cleanup for exit check

A few cleanups and consistency fixes for the i3/sway exit check scripts:
* echo's behaviour is unagreed upon, both in terms of whether an `-e`
  option exists and whether or not newline literals are interpreted as
  newlines by default. Instead, use the shell printf function, which was
  added precisely because echo's behaviour differs so much between
  shells. This came up because Debian's default /bin/sh is dash, which
  does not include an -e option.
* Instead of checking `$?` for the result of `which wofi` we check for a
  non-zero exit code directly.
* Use $() command substitution notation rather than backticks. As far as
  I know, all /bin/sh implementations I use support this these days.

Diffstat:
M.config/i3/exit_check.sh | 2+-
M.config/sway/exit_check.sh | 5++---
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/.config/i3/exit_check.sh b/.config/i3/exit_check.sh @@ -7,7 +7,7 @@ unset XMODIFIERS while [ "$choice" != "no" ] && [ "$choice" != "yes" ]; do - choice=`echo -e 'no\nyes' | dmenu -fn "DejaVu Sans Mono-12" -p "Really exit?"` + choice=$(printf 'no\nyes\n' | dmenu -fn "DejaVu Sans Mono-12" -p "Really exit?") done if [ "$choice" = "yes" ]; then i3-msg exit diff --git a/.config/sway/exit_check.sh b/.config/sway/exit_check.sh @@ -3,13 +3,12 @@ # Use wofi to check if the user wants to exit sway. # If wofi isn't installed, bail out immediately. -which wofi -if [ $? != 0 ]; then +if ! which wofi; then swaymsg exit fi while [ "$choice" != "no" ] && [ "$choice" != "yes" ]; do - choice=$(echo -e 'no\nyes' | wofi --show dmenu -p "Really exit?") + choice=$(printf 'no\nyes\n' | wofi --show dmenu -p "Really exit?") done if [ "$choice" = "yes" ]; then swaymsg exit