2024-08-25 01:58:41 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# superclick-desktop = actions for w-Leftmouseclick event on desktop
|
|
|
|
|
|
|
|
CONFIG_FILE="$HOME/.config/mabox/superclick-desktop.conf"
|
|
|
|
|
|
|
|
if [ ! -f ${CONFIG_FILE} ]; then
|
|
|
|
cat <<EOF > ${CONFIG_FILE}
|
|
|
|
# SuperClick on desktop config file
|
|
|
|
# Sidearea width in pixels
|
|
|
|
sidewidth=300
|
|
|
|
# Commands to run on super + clik on left, center or right desktop area
|
|
|
|
left_cmd="mb-jgtools places 2>/dev/null"
|
|
|
|
center_cmd="jgdesktops -s 2>/dev/null"
|
|
|
|
right_cmd="mb-jgtools right 2>/dev/null"
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
# read config variables from file
|
|
|
|
source <(grep = $CONFIG_FILE)
|
|
|
|
|
|
|
|
SIDEWIDTH=${sidewidth:-0}
|
|
|
|
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"}
|
|
|
|
|
|
|
|
|
2024-08-25 11:14:12 +02:00
|
|
|
# Get mouse location (we need X here)
|
2024-08-25 01:58:41 +02:00
|
|
|
eval $(xdotool getmouselocation --shell)
|
|
|
|
|
2024-08-25 11:14:12 +02:00
|
|
|
# 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
|
2024-08-25 01:58:41 +02:00
|
|
|
bash <<< "$LEFT_CMD"
|
2024-08-25 11:14:12 +02:00
|
|
|
elif [ $X -gt $((M_X_OFF+M_WIDTH-SIDEWIDTH)) ];then
|
2024-08-25 01:58:41 +02:00
|
|
|
bash <<< "$RIGHT_CMD"
|
|
|
|
else
|
|
|
|
bash <<< "$CENTER_CMD"
|
|
|
|
fi
|