Merge pull request #1928 from r3claimer/next

Add hotkey support to swap the outout display on devices like the thor
This commit is contained in:
r3claimer
2025-10-28 15:12:01 -07:00
committed by GitHub
4 changed files with 38 additions and 2 deletions

View File

@@ -69,7 +69,7 @@
FIRMWARE=""
# Additional packages to install
ADDITIONAL_PACKAGES="u-boot"
ADDITIONAL_PACKAGES="u-boot screen-switch"
# Debug tty path
DEBUG_TTY="/dev/ttyMSM0"

View File

@@ -0,0 +1,16 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2025 ROCKNIX (https://github.com/ROCKNIX)
PKG_NAME="screen-switch"
PKG_VERSION="1.0"
PKG_LICENSE="GPLv3"
PKG_DEPENDS_TARGET="toolchain sway"
PKG_LONGDESC="A simple script to swap sway output screens"
PKG_TOOLCHAIN="manual"
PKG_PATCH_DIRS+="${DEVICE}"
makeinstall_target() {
mkdir -p ${INSTALL}/usr/bin
cp -rf ${PKG_DIR}/scripts/screen_switch ${INSTALL}/usr/bin
chmod 0755 ${INSTALL}/usr/bin/*
}

View File

@@ -0,0 +1,13 @@
#!/bin/bash
source /etc/profile
# Get the active app_id
ACTIVE_APPID=$(swaymsg -t get_tree | awk '
/"focused": true/ {focused=1}
focused && /app_id/ {gsub(/.*"app_id": *"/,""); gsub(/".*/,""); print; exit}
')
UDSI=$(swaymsg -t get_tree | jq -r '.. | objects | select(.type == "output" and .name != "__i3") | select(.nodes[].nodes | length == 0) | .name')
swaymsg [app_id=\"${ACTIVE_APPID}\"] move window to output ${UDSI}

View File

@@ -69,6 +69,7 @@ FUNCTION_HOTKEY_C_EVENT='*('${BTN_HOTKEY_C_MODIFIER}'), value *'
FUNCTION_HOTKEY_BTN_WEST_EVENT="*(BTN_WEST), value 1*"
FUNCTION_HOTKEY_BTN_EAST_EVENT="*(BTN_EAST), value 1*"
FUNCTION_HOTKEY_BTN_BACK_EVENT="*(BTN_BACK), value 1*"
FUNCTION_HOTKEY_TOUCH_EVENT="*(BTN_TOUCH), value 1*"
@@ -456,5 +457,11 @@ set +e
/usr/bin/mangohud_set toggle
fi
;;
esac
(${FUNCTION_HOTKEY_BTN_BACK_EVENT})
if [ "${HOTKEY_A_PRESSED}" = true ]; then
${DEBUG} && log $0 "${FUNCTION_HOTKEY_BTN_BACK_EVENT}: Switch Screen Output"
/usr/bin/screen_switch
fi
;;
esac
done