pgrep is a little slow, slower than ps | grep

This commit is contained in:
Luke Smith 2020-04-11 10:03:33 -04:00
parent 7b9277ae0b
commit 080365dd22
No known key found for this signature in database
GPG key ID: 4C50B54A911F6252
6 changed files with 7 additions and 7 deletions

View file

@ -7,7 +7,7 @@ ping -q -c 1 1.1.1.1 > /dev/null || exit
/usr/bin/notify-send "📰 Updating RSS feeds..." /usr/bin/notify-send "📰 Updating RSS feeds..."
pgrep -x newsboat >/dev/null && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit ps ax | grep -q newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit
echo 🔃 > /tmp/newsupdate echo 🔃 > /tmp/newsupdate
pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}" pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"

View file

@ -69,4 +69,4 @@ esac
setbg # Fix background if screen size/arangement has changed. setbg # Fix background if screen size/arangement has changed.
remaps # Re-remap keys if keyboard added (for laptop bases) remaps # Re-remap keys if keyboard added (for laptop bases)
pgrep -x dunst >/dev/null && killall dunst && setsid dunst & # Restart dunst to ensure proper location on screen { killall dunst ; setsid dunst & } >/dev/null 2>&1 # Restart dunst to ensure proper location on screen

View file

@ -4,7 +4,7 @@
killall -q polybar killall -q polybar
# Wait until the processes have been shut down # Wait until the processes have been shut down
while pgrep -x polybar >/dev/null; do sleep 1; done while ps ax | grep -q "\spolybar$"; do sleep 1; done
for i in $(polybar -m | awk -F: '{print $1}'); do MONITOR=$i polybar default & done for i in $(polybar -m | awk -F: '{print $1}'); do MONITOR=$i polybar default & done

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# If transmission-daemon is running, will ask to kill, else will ask to start. # If transmission-daemon is running, will ask to kill, else will ask to start.
if pgrep -x transmission-da >/dev/null ; if ps ax | grep -q "\stransmission-daemon$" ;
then then
[ "$(printf "No\\nYes" | dmenu -i -p "Kill transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon killed." [ "$(printf "No\\nYes" | dmenu -i -p "Kill transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon killed."
else else

View file

@ -2,6 +2,6 @@
ifinstalled tremc transmission-cli || exit ifinstalled tremc transmission-cli || exit
! pgrep -x transmission-da >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}" ! ps ax | grep -q "\stransmission-daemon$" && transmission-daemon && notify-send "Starting torrent daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}" &
$TERMINAL -e tremc $TERMINAL -e tremc

View file

@ -2,8 +2,8 @@
# Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running. # Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running.
# transmission-daemon sometimes fails to take remote requests in its first moments. # transmission-daemon sometimes fails to take remote requests in its first moments, hence the sleep.
pgrep -x transmission-da || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}") ps ax | grep -q "\stransmission-daemon$" || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}") &
transmission-remote -a "$@" && notify-send "🔽 Torrent added." transmission-remote -a "$@" && notify-send "🔽 Torrent added."