Created
February 4, 2022 11:41
-
-
Save NightFeather/41a2422f1b3ac8519ebf1a1bf1aff88d to your computer and use it in GitHub Desktop.
Auto open albert when not running under swaywm.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function retry() { | |
if [[ $# -lt 3 ]]; then | |
return 1 | |
fi | |
limit=$1 | |
shift | |
timeout=$1 | |
shift | |
count=0 | |
while [[ $count -lt $limit ]]; do | |
$@ | |
if [[ $? -eq 0 ]]; then | |
return 0 | |
else | |
count=$(expr $count + 1) | |
fi | |
sleep $timeout | |
done | |
return 1 | |
} | |
set -x | |
albert toggle | |
if [[ $? -ne 0 ]]; then | |
sleep .1 | |
pgrep -x albert | |
if [[ $? -ne 0 ]]; then | |
notify-send 'Please wait' 'It looks like albert is not running, starting it...' | |
swaymsg exec albert | |
else | |
notify-send 'Please wait' 'It looks like albert is not responding, retrying...' | |
retry 3 1 albert toggle | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment