51 lines
1.4 KiB
Bash
Executable File
51 lines
1.4 KiB
Bash
Executable File
#!/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"}
|
|
|
|
|
|
# Get mouse location (we need X here)
|
|
eval $(xdotool getmouselocation --shell)
|
|
|
|
# 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 $((M_X_OFF+M_WIDTH-SIDEWIDTH)) ];then
|
|
bash <<< "$RIGHT_CMD"
|
|
else
|
|
bash <<< "$CENTER_CMD"
|
|
fi
|