From fcdd6fc414b09814e0c43d26681f2c074ab22c92 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 4 Nov 2023 13:39:48 -0400 Subject: [PATCH] feat(ags): implement tablet service in bar --- devices/wim/config/ags/bin/tablet-toggle.sh | 39 -------------- .../wim/config/ags/js/bar/tablet-toggle.js | 13 +++-- devices/wim/config/gtklock/scripts/lock.sh | 2 +- devices/wim/config/hypr/main.conf | 2 +- devices/wim/config/hypr/scripts/autorotate.sh | 51 ------------------- 5 files changed, 8 insertions(+), 99 deletions(-) delete mode 100755 devices/wim/config/ags/bin/tablet-toggle.sh delete mode 100755 devices/wim/config/hypr/scripts/autorotate.sh diff --git a/devices/wim/config/ags/bin/tablet-toggle.sh b/devices/wim/config/ags/bin/tablet-toggle.sh deleted file mode 100755 index dede8568..00000000 --- a/devices/wim/config/ags/bin/tablet-toggle.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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" & - evtest --grab "/dev/touchpad" & -} - -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 -} - -[[ $1 == "toggle" ]] && toggle -[[ $1 == "laptop" ]] && laptop -[[ $1 == "tablet" ]] && tablet diff --git a/devices/wim/config/ags/js/bar/tablet-toggle.js b/devices/wim/config/ags/js/bar/tablet-toggle.js index 4847ee26..0a93d009 100644 --- a/devices/wim/config/ags/js/bar/tablet-toggle.js +++ b/devices/wim/config/ags/js/bar/tablet-toggle.js @@ -1,17 +1,16 @@ import { Box, Label } from 'resource:///com/github/Aylur/ags/widget.js'; -import { subprocess } from 'resource:///com/github/Aylur/ags/utils.js'; import EventBox from '../misc/cursorbox.js'; export default () => EventBox({ className: 'toggle-off', - onPrimaryClickRelease: self => { - subprocess( - ['bash', '-c', '$AGS_PATH/tablet-toggle.sh toggle'], - output => self.toggleClassName('toggle-on', output == 'Tablet'), - ); - }, + onPrimaryClickRelease: () => Tablet.toggleMode(), + + connections: [[Tablet, self => { + self.toggleClassName('toggle-on', Tablet.tabletMode); + }, 'mode-toggled']], + child: Box({ className: 'tablet-toggle', vertical: false, diff --git a/devices/wim/config/gtklock/scripts/lock.sh b/devices/wim/config/gtklock/scripts/lock.sh index a2bbcf8b..e16566a1 100755 --- a/devices/wim/config/gtklock/scripts/lock.sh +++ b/devices/wim/config/gtklock/scripts/lock.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash -$AGS_PATH/tablet-toggle.sh laptop & +ags -r 'Tablet.setLaptopMode()' $LOCK_PATH/blur.sh gtklock diff --git a/devices/wim/config/hypr/main.conf b/devices/wim/config/hypr/main.conf index 64e69211..89419854 100644 --- a/devices/wim/config/hypr/main.conf +++ b/devices/wim/config/hypr/main.conf @@ -12,7 +12,7 @@ xwayland { } # See https://wiki.hyprland.org/Configuring/Monitors/ x y -monitor=desc:Acer Technologies Acer K212HQL T3EAA0014201, 1920x1080@60, 840x1000, 1, transform, 3 +monitor=desc:Acer Technologies Acer K212HQL T3EAA0014201, 1920x1080@60, 840x1000, 1, transform, 3 monitor=desc:BOE 0x0964, 1920x1200@60, 0x2920, 1 monitor=desc:Samsung Electric Company C27JG5x HTOM100586, 2560x1440@144, 1920x120, 1 # Desc of monitor has comma, so force its default on everything and specify everything else diff --git a/devices/wim/config/hypr/scripts/autorotate.sh b/devices/wim/config/hypr/scripts/autorotate.sh deleted file mode 100755 index 347b58b3..00000000 --- a/devices/wim/config/hypr/scripts/autorotate.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -# This script was forked from https://gitlab.com/snippets/1793649 by Fishonadish - - -SCREEN="eDP-1" -WAYLANDINPUT=("wacom-hid-52eb-finger" - "wacom-hid-52eb-pen") - - - -function rotate_ms { - if [[ $(hyprctl activewindow | grep Waydroid) == "" ]]; then - case $1 in - "normal") - rotate 0 - ;; - "right-up") - rotate 3 - ;; - "bottom-up") - rotate 2 - ;; - "left-up") - rotate 1 - ;; - esac - elif [[ $(hyprctl monitors | grep "transform: 0") == "" ]]; then - rotate 0 - fi -} - -function rotate { - TARGET_ORIENTATION=$1 - - echo "Rotating to" $TARGET_ORIENTATION - - hyprctl keyword monitor $SCREEN,transform,$TARGET_ORIENTATION - - for i in "${WAYLANDINPUT[@]}" - do - hyprctl keyword device:"$i":transform $TARGET_ORIENTATION - done - - $HYPR_PATH/lisgd.sh & -} - -while IFS='$\n' read -r line; do - rotation="$(echo $line | sed -En "s/^.*orientation changed: (.*)/\1/p")" - [[ ! -z $rotation ]] && rotate_ms $rotation -done < <(stdbuf -oL monitor-sensor)