Skip to content

Commit

Permalink
Fix duplicate processes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nalipaz committed Mar 23, 2015
1 parent ce3ba93 commit d2accdf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 33 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
poll-xrandr (1.5) stable; urgency=medium

* Check for existing processes before running again.

-- Nicholas Alipaz <[email protected]> Mon, 23 Mar 2015 09:00:16 -0700

poll-xrandr (1.4) stable; urgency=medium

* Remove the postint that I mistakenly added to wrong project.
Expand Down
2 changes: 1 addition & 1 deletion equivs.control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Priority: optional
Homepage: https://github.com/nalipaz/poll-xrandr
Standards-Version: 3.9.2
Package: poll-xrandr
Version: 1.4
iVersion: 1.5
Maintainer: Nicholas Alipaz <[email protected]>
Depends: grep, coreutils
Architecture: all
Expand Down
70 changes: 38 additions & 32 deletions poll-xrandr
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,43 @@ Application Options:
exit
fi

i=4 # default interval for polling.

connected="$(xrandr -q | grep " connected"|cut -d ' ' -f1|xargs)"

# Endless loop
while : ; do
# Re-read the status
#new_cat="`cat $f`"
connected_recheck="$(xrandr -q | grep " connected"|cut -d ' ' -f1|xargs)"

# If original contents don't match new we need to run command.
if [ "$connected" != "$connected_recheck" ]; then
# Set the original contents the same as new to avoid unnecessarily repeating
connected=$connected_recheck
autorandr --change --force
fi

shift 1
while [[ $# > 0 ]]; do
key=$1

case $key in
-i=*|--interval=*)
i="${key#*=}"
;;
*)
echo "Unknown option provided, you should fix that."
;;
esac
shift
if [ -z "$(pgrep poll-xrandr)" ]; then
i=4 # default interval for polling.

connected="$(xrandr -q | grep " connected"|cut -d ' ' -f1|xargs)"

# Endless loop
while : ; do
# Re-read the status
#new_cat="`cat $f`"
connected_recheck="$(xrandr -q | grep " connected"|cut -d ' ' -f1|xargs)"

# If original contents don't match new we need to run command.
if [ "$connected" != "$connected_recheck" ]; then
# Set the original contents the same as new to avoid unnecessarily repeating
connected=$connected_recheck
autorandr --change --force
fi

shift 1
while [[ $# > 0 ]]; do
key=$1

case $key in
-i=*|--interval=*)
i="${key#*=}"
;;
*)
echo "Unknown option provided, you should fix that."
;;
esac
shift
done

sleep $i
done

sleep $i
done
else
echo "poll-xrandr is already running: aborting..."
exit
fi

0 comments on commit d2accdf

Please sign in to comment.