feat(ags): implement tablet service in bar

This commit is contained in:
matt1432 2023-11-04 13:39:48 -04:00
parent 97239557f7
commit fcdd6fc414
5 changed files with 8 additions and 99 deletions

View file

@ -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

View file

@ -1,17 +1,16 @@
import { Box, Label } from 'resource:///com/github/Aylur/ags/widget.js'; 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'; import EventBox from '../misc/cursorbox.js';
export default () => EventBox({ export default () => EventBox({
className: 'toggle-off', className: 'toggle-off',
onPrimaryClickRelease: self => { onPrimaryClickRelease: () => Tablet.toggleMode(),
subprocess(
['bash', '-c', '$AGS_PATH/tablet-toggle.sh toggle'], connections: [[Tablet, self => {
output => self.toggleClassName('toggle-on', output == 'Tablet'), self.toggleClassName('toggle-on', Tablet.tabletMode);
); }, 'mode-toggled']],
},
child: Box({ child: Box({
className: 'tablet-toggle', className: 'tablet-toggle',
vertical: false, vertical: false,

View file

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
$AGS_PATH/tablet-toggle.sh laptop & ags -r 'Tablet.setLaptopMode()'
$LOCK_PATH/blur.sh $LOCK_PATH/blur.sh
gtklock gtklock

View file

@ -12,7 +12,7 @@ xwayland {
} }
# See https://wiki.hyprland.org/Configuring/Monitors/ x y # 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:BOE 0x0964, 1920x1200@60, 0x2920, 1
monitor=desc:Samsung Electric Company C27JG5x HTOM100586, 2560x1440@144, 1920x120, 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 # Desc of monitor has comma, so force its default on everything and specify everything else

View file

@ -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)