feat(ags): make logic behind tablet mode toggle

This commit is contained in:
matt1432 2023-09-05 13:25:32 -04:00
parent 23e50efee0
commit ba200fb9b7
3 changed files with 57 additions and 4 deletions

38
config/ags/bin/tablet-toggle.sh Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
tablet() {
gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true
brightnessctl -d tpacpi::kbd_backlight s 0
"$HYPR_PATH"/autorotate.sh &
evtest --grab "/dev/input/by-path/platform-i8042-serio-0-event-kbd" &
evtest --grab "/dev/input/by-path/platform-i8042-serio-1-event-mouse" &
evtest --grab "/dev/input/by-path/platform-AMDI0010:02-event-mouse" &
evtest --grab "/dev/input/by-path/platform-thinkpad_acpi-event" &
evtest --grab "/dev/video-bus" &
}
laptop() {
gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false
brightnessctl -d tpacpi::kbd_backlight s 2
killall -r autorotate.sh
killall -r evtest
}
toggle () {
if [[ "$(gsettings get org.gnome.desktop.a11y.applications screen-keyboard-enabled)" == "false" ]]; then
echo "Tablet"
tablet > /dev/null
else
echo "Laptop"
laptop > /dev/null
fi
}
if [[ $1 == "toggle" ]];then
toggle
fi

View file

@ -1,12 +1,27 @@
const { Box, Label } = ags.Widget;
const { subprocess } = ags.Utils;
import { EventBox } from '../common.js'; import { EventBox } from '../common.js';
export const TabletToggle = EventBox({ export const TabletToggle = EventBox({
className: 'toggle-off', className: 'toggle-off',
onPrimaryClickRelease: '', onPrimaryClickRelease: function() {
child: ags.Widget.Box({ subprocess(
['bash', '-c', '/home/matt/.nix/config/ags/bin/tablet-toggle.sh toggle'],
(output) => {
print(output)
if (output == 'Tablet') {
TabletToggle.toggleClassName('toggle-on', true);
} else {
TabletToggle.toggleClassName('toggle-on', false);
}
},
);
},
child: Box({
className: 'tablet-toggle', className: 'tablet-toggle',
vertical: false, vertical: false,
child: ags.Widget.Label({ child: Label({
label: " 󰦧 ", label: " 󰦧 ",
}), }),
}), }),