diff options
author | luukvbaal <31730729+luukvbaal@users.noreply.github.com> | 2019-05-13 12:46:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-13 12:46:03 +0200 |
commit | 15eeddc2358e9bd337dfbf5e8735b59987d3f4c4 (patch) | |
tree | f7b71df701b65f7024d1c2f838f0a62937134f59 /bin | |
parent | b6a60f896557367782e1ff6c688233e1e7e56037 (diff) |
don't allow to be run concurrently with itself
This allows mailsync to be called like this `bindsym $mod+e exec --no-startup-id mailsync; exec $term -e neomutt && pkill -RTMIN+12 i3blocks` such that it refreshes your mail when you open mutt without it needlessly syncing if a sync is already running.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mailsync | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/bin/mailsync b/bin/mailsync index 43429f5..8da6629 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -3,6 +3,8 @@ # Run only if user logged in (prevent cron errors) pgrep -cu "$USER" >/dev/null || exit +# Run only if not already running in other instance +[ $(pgrep -xf "sh /usr/bin/mailsync" | wc -l) -eq 2 ] || exit # Checks for internet connection and set notification script. ping -q -c 1 1.1.1.1 > /dev/null || exit |