mabox-tools/bin/superclick-desktop

40 lines
1.1 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"}
# 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))
eval $(xdotool getmouselocation --shell)
if [ $X -lt ${sidewidth} ];then
bash <<< "$LEFT_CMD"
elif [ $X -gt ${RIGHT} ];then
bash <<< "$RIGHT_CMD"
else
bash <<< "$CENTER_CMD"
fi