Skip to content

Instantly share code, notes, and snippets.

@NightFeather
Created February 4, 2022 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NightFeather/41a2422f1b3ac8519ebf1a1bf1aff88d to your computer and use it in GitHub Desktop.
Save NightFeather/41a2422f1b3ac8519ebf1a1bf1aff88d to your computer and use it in GitHub Desktop.
Auto open albert when not running under swaywm.
#!/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