From a1f485d6e514295d2c0cb20abf1d474b61e84415 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 28 May 2023 19:54:01 -0400 Subject: [PATCH] change location of scripts to add to repo --- sway/scripts/tablet/autorotate.sh | 63 ++++++++++++++++++++++++++++ sway/scripts/tablet/laptop-mode.sh | 10 +++++ sway/scripts/tablet/osk-toggle.sh | 10 +++++ sway/scripts/tablet/tablet-mode.sh | 8 ++++ sway/scripts/tablet/tablet-toggle.sh | 7 ++++ waybar/config | 6 +-- waybar/scripts/quick-toggle.sh | 7 ++++ 7 files changed, 108 insertions(+), 3 deletions(-) create mode 100755 sway/scripts/tablet/autorotate.sh create mode 100755 sway/scripts/tablet/laptop-mode.sh create mode 100755 sway/scripts/tablet/osk-toggle.sh create mode 100755 sway/scripts/tablet/tablet-mode.sh create mode 100755 sway/scripts/tablet/tablet-toggle.sh create mode 100755 waybar/scripts/quick-toggle.sh diff --git a/sway/scripts/tablet/autorotate.sh b/sway/scripts/tablet/autorotate.sh new file mode 100755 index 00000000..77340c44 --- /dev/null +++ b/sway/scripts/tablet/autorotate.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# This script handles rotation of the screen and related input devices automatically +# using the output of the monitor-sensor command (part of the iio-sensor-proxy package) +# for sway. +# The target screen and input device names should be configured in the below variables. +# Note: input devices using the libinput driver (e.g. touchscreens) should be included +# in the WAYLANDINPUT array. +# +# You can get a list of input devices with the `swaymsg -t output` command. +# +# This script was forked from https://gitlab.com/snippets/1793649 by Fishonadish + + +SCREEN="eDP-1" +WAYLANDINPUT=("1386:21227:Wacom_HID_52EB_Finger" + "1386:21227:Wacom_HID_52EB_Pen") + + +function rotate_ms { + case $1 in + "normal") + rotate 0 + /home/matt/.config/lisgd/config & + ;; + "right-up") + rotate 90 + /home/matt/.config/lisgd/config & + ;; + "bottom-up") + rotate 180 + /home/matt/.config/lisgd/config & + ;; + "left-up") + rotate 270 + /home/matt/.config/lisgd/config & + ;; + esac +} + +function rotate { + swww img $HOME/Pictures/BG/black.jpg + sleep 0.1 + + TARGET_ORIENTATION=$1 + + echo "Rotating to" $TARGET_ORIENTATION + + swaymsg output $SCREEN transform $TARGET_ORIENTATION + swww img $HOME/Pictures/BG/bonzai.jpg + + for i in "${WAYLANDINPUT[@]}" + do + swaymsg input "$i" map_to_output "$SCREEN" + done + +} + +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) + diff --git a/sway/scripts/tablet/laptop-mode.sh b/sway/scripts/tablet/laptop-mode.sh new file mode 100755 index 00000000..8b8c6de8 --- /dev/null +++ b/sway/scripts/tablet/laptop-mode.sh @@ -0,0 +1,10 @@ +#!/bin/bash +/usr/bin/setsysmode laptop + +gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false + +brightnessctl -d tpacpi::kbd_backlight s 2 + +killall autorotate.sh +swaymsg output eDP-1 transform 0 +$HOME/.config/lisgd/config diff --git a/sway/scripts/tablet/osk-toggle.sh b/sway/scripts/tablet/osk-toggle.sh new file mode 100755 index 00000000..1ed9e904 --- /dev/null +++ b/sway/scripts/tablet/osk-toggle.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +if [[ $(busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible) == "b true" ]] +then + echo "Running" + busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false +else + echo "Stopped" + busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true +fi diff --git a/sway/scripts/tablet/tablet-mode.sh b/sway/scripts/tablet/tablet-mode.sh new file mode 100755 index 00000000..c407c614 --- /dev/null +++ b/sway/scripts/tablet/tablet-mode.sh @@ -0,0 +1,8 @@ +#!/bin/bash +setsysmode tablet + +gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true + +brightnessctl -d tpacpi::kbd_backlight s 0 + +$HOME/.config/sway/scripts/tablet/autorotate.sh diff --git a/sway/scripts/tablet/tablet-toggle.sh b/sway/scripts/tablet/tablet-toggle.sh new file mode 100755 index 00000000..7da1df32 --- /dev/null +++ b/sway/scripts/tablet/tablet-toggle.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [[ $(gsettings get org.gnome.desktop.a11y.applications screen-keyboard-enabled) == true ]]; then + $HOME/.config/sway/scripts/tablet/laptop-mode.sh +else + $HOME/.config/sway/scripts/tablet/tablet-mode.sh +fi diff --git a/waybar/config b/waybar/config index 8409fd8a..ddaacc3a 100644 --- a/waybar/config +++ b/waybar/config @@ -82,19 +82,19 @@ }, "custom/osk": { "format":" 󰌌 ", - "on-click": "$HOME/.scripts/osk-toggle.sh", + "on-click": "$HOME/.config/sway/scripts/tablet/osk-toggle.sh", "restart-interval": 1, }, "custom/quicksettings": { "format":"  ", - "on-click": "$HOME/.scripts/quick-toggle.sh", + "on-click": "$HOME/.config/waybar/scripts/quick-toggle.sh", "restart-interval": 1, }, "custom/tablet": { "format":" 󰦧 ", - "on-click": "$HOME/.scripts/tablet-toggle.sh", + "on-click": "$HOME/.config/sway/scripts/tablet/tablet-toggle.sh", "restart-interval": 1, }, diff --git a/waybar/scripts/quick-toggle.sh b/waybar/scripts/quick-toggle.sh new file mode 100755 index 00000000..7aa11cd6 --- /dev/null +++ b/waybar/scripts/quick-toggle.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [[ $(eww state | grep br_icon) ]]; then + eww close actions && eww close actions-closer +else + eww open actions && eww open actions-closer +fi