diff --git a/bin/superclick-desktop b/bin/superclick-desktop index 43e3c97..4b472df 100755 --- a/bin/superclick-desktop +++ b/bin/superclick-desktop @@ -24,15 +24,26 @@ CENTER_CMD=${center_cmd:-"jgdesktops -s 2>/dev/null"} LEFT_CMD=${left_cmd:-"mb-jgtools places 2>/dev/null"} RIGHT_CMD=${right_cmd:-"mb-jgtools right 2>/dev/null"} -# TODO: Make it work on dual monitor setups - buy second monitor and look how it is implemented in superclick script ;) -MON_WIDTH=$(xrandr | grep " connected" |awk '{print $3}' |awk -F[x+] '{print $1}') -RIGHT=$((MON_WIDTH-sidewidth)) +# Get mouse location (we need X here) eval $(xdotool getmouselocation --shell) -if [ $X -lt ${sidewidth} ];then +# get monitor width and x-offset on current monitor (the one where pointer is) +while read -r line; do + info=$(echo $line | awk '{print $3}') + if [[ $info == primary ]]; then + info=$(echo $line | awk '{print $4}') + fi + read M_WIDTH M_X_OFF <<< $(echo $info | awk -F[x+] '{print $1, $3}') + if (( X >= M_X_OFF && X <= M_WIDTH + M_X_OFF )); then + break + fi +done < <(xrandr | grep " connected") + + +if [ $X -lt $((M_X_OFF+SIDEWIDTH)) ];then bash <<< "$LEFT_CMD" -elif [ $X -gt ${RIGHT} ];then +elif [ $X -gt $((M_X_OFF+M_WIDTH-SIDEWIDTH)) ];then bash <<< "$RIGHT_CMD" else bash <<< "$CENTER_CMD"