window-manager/scripts/keyboard.sh

94 lines
No EOL
1.9 KiB
Bash
Executable file

#!/bin/bash
IS_ACTIVE="false"
SCRIPT_LOCATION="$(realpath "$0")"
if [ -z "$1" ]; then
if [ $IS_ACTIVE = "true" ]; then
"$SCRIPT_LOCATION" hide;
else
"$SCRIPT_LOCATION" show;
fi
exit 0;
fi
if [ "$1" == "--no-rotate" ]; then
if [ $IS_ACTIVE = "true" ]; then
"$SCRIPT_LOCATION" hide --no-rotate;
else
"$SCRIPT_LOCATION" show --no-rotate;
fi
exit 0;
fi
if [ "$1" == "hide" ]; then
killall -s SIGUSR1 wvkbd-deskintl;
"$SCRIPT_LOCATION" reset;
if [ -z "$2" ]; then
hyprctl keyword monitor eDP-1,preferred,0x0,1,transform,0
hyprctl keyword input:tablet:transform 0
hyprctl keyword input:touchdevice:transform 0
exit 0;
elif [ "$2" == "--no-rotate" ]; then
exit 0;
else
echo "Unknown flag: $2";
fi
exit 1;
fi
if [ "$1" == "show" ]; then
killall -s SIGUSR2 wvkbd-deskintl;
sed -i "s/IS_ACTIVE=\"false\"/IS_ACTIVE=\"true\"/" "$SCRIPT_LOCATION";
if [ -z "$2" ]; then
hyprctl keyword monitor eDP-1,preferred,0x0,1,transform,1
hyprctl keyword input:tablet:transform 1
hyprctl keyword input:touchdevice:transform 1
exit 0;
elif [ "$2" == "--no-rotate" ]; then
exit 0;
else
echo "Unknown flag: $2";
fi
exit 1;
fi
if [ "$1" == "json" ]; then
if [ $IS_ACTIVE = "true" ]; then
STATE="active"
ACTION="Hide"
ACTION_PL="Ukryj"
else
STATE="hidden"
ACTION="Show"
ACTION_PL="Pokaż"
fi
echo "{\"state\":\"${STATE}\",\"alt\":\"${ACTION}\",\"action\":{\"en\":\"${ACTION}\",\"pl\":\"${ACTION_PL}\"}}";
exit 0;
fi
if [ "$1" == "status" ]; then
if [ $IS_ACTIVE = "true" ]; then
echo "active";
else
echo "hidden";
fi
exit 0;
fi
if [ "$1" == "reset" ]; then
sed -i "s/IS_ACTIVE=\"true\"/IS_ACTIVE=\"false\"/" "$SCRIPT_LOCATION";
exit 0;
fi
if [ "$1" == "help" ]; then
echo "params: --no-rotate|hide [--no-rotate]|show [--no-rotate]|json|status|reset|help";
echo "no param: toggle";
exit 0;
fi
echo "Unknown command \"${SCRIPT_LOCATION} $1\", use \"${SCRIPT_LOCATION} help\" for help.";
exit 1;