From cfc69a2728f32c4efa119efab0a49022638845a9 Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Sun, 25 Aug 2024 11:14:12 +0200 Subject: [PATCH] superclick-desktop update --- bin/superclick-desktop | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) 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"