From 30e771058c7669fe49d57c5fcfb8b96b937136a4 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 21 Feb 2022 10:58:53 +0100 Subject: Removed bashism in sxhkd scripts --- sxhkd/scripts/sxhkd/rofi_new.sh | 28 +++++++++++++++++++++++----- sxhkd/scripts/sxhkd/rofi_rotate.sh | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sxhkd/scripts/sxhkd/rofi_new.sh b/sxhkd/scripts/sxhkd/rofi_new.sh index b1e19d8..a5093cd 100755 --- a/sxhkd/scripts/sxhkd/rofi_new.sh +++ b/sxhkd/scripts/sxhkd/rofi_new.sh @@ -1,9 +1,27 @@ -#!/bin/bash +#!/bin/sh + +tmpdir=$(mktemp -d) + +on_exit() { + rm -r "${tmpdir}" +} + +on_preExit() { + on_exit +} + +trap on_exit EXIT # EXIT = 0 +trap on_preExit HUP INT QUIT TERM STOP PWR # 1 2 3 15 30 + if [ -z $1 ]; then - cat <(echo -e "Chat\nWeb\nMail\nMusique") <(bspc query --names -D) | sort -u + # We are using dash, the process substitution syntax is not allowed + # sort -u <(…) <(…) + # so, we are using pipes for that + mkfifo ${tmpdir}/p1 ${tmpdir}/p2 + echo "Chat\nWeb\nMail\nMusique" > "${tmpdir}/p1" & + bspc query --names -D > "${tmpdir}/p2" & + sort -u "${tmpdir}/p1" "${tmpdir}/p2" else - for desktop in $(echo $1 | tr "," "\n"); do - ~/scripts/sxhkd/show.sh $desktop - done + ~/scripts/sxhkd/show.sh $1 fi diff --git a/sxhkd/scripts/sxhkd/rofi_rotate.sh b/sxhkd/scripts/sxhkd/rofi_rotate.sh index 6438f2a..82ee234 100755 --- a/sxhkd/scripts/sxhkd/rofi_rotate.sh +++ b/sxhkd/scripts/sxhkd/rofi_rotate.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh if [ -z $1 ]; then echo "Horaire" echo "Antihoraire" -- cgit v1.2.3