get rid of pidof as well as handle starting when pidfile exists and the process is not running

This commit is contained in:
Von Random 2015-06-24 23:01:46 +03:00
parent 5ba50b5abc
commit a9074004eb

View file

@ -1,20 +1,26 @@
#!/usr/bin/zsh #!/usr/bin/zsh
nvidia_dev='/dev/nvidia0' nvidia_dev='/dev/nvidia0'
lockfile='/tmp/compton.lock' pidfile='/tmp/compton.pid'
if [[ -r $lockfile ]]; then
read pid < $lockfile if [[ -r $pidfile ]]; then
kill $pid read pid < $pidfile
rm $lockfile rm $pidfile
else if kill $pid; then
exit 0
fi
fi
if [[ -e $nvidia_dev ]]; then if [[ -e $nvidia_dev ]]; then
vsync_backend='opengl' vsync_backend='opengl'
else else
vsync_backend='drm' vsync_backend='drm'
fi fi
compton --vsync $vsync_backend --unredir-if-possible --paint-on-overlay -cGCb -t-5 -l-5 -r4 -o.55 -m.95 compton --vsync $vsync_backend -cGC -t-5 -l-5 -r4 -o.55 -m.9 &
pid=$(pidof compton) pid=$!
if [[ -n $pid ]]; then if [[ -n $pid ]]; then
printf '%s' $pid > $lockfile printf '%s' $pid > $pidfile
fi else
exit 1
fi fi
disown
exit 0 exit 0