Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/ROCKNIX/devices/SM8250/options
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
FIRMWARE="extra-firmware"

# Additional packages to install
ADDITIONAL_PACKAGES="gamepadcalibration screen-switch inputplumber rocknix-abl"
ADDITIONAL_PACKAGES="gamepadcalibration inputplumber rocknix-abl"

# Debug tty path
DEBUG_TTY="/dev/ttyMSM0"
Expand Down
2 changes: 1 addition & 1 deletion projects/ROCKNIX/devices/SM8550/options
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
FIRMWARE=""

# Additional packages to install
ADDITIONAL_PACKAGES="gamepadcalibration screen-switch rocknix-abl inputplumber"
ADDITIONAL_PACKAGES="gamepadcalibration rocknix-abl inputplumber"

# Debug tty path
DEBUG_TTY="/dev/ttyMSM0"
Expand Down
16 changes: 0 additions & 16 deletions projects/ROCKNIX/packages/apps/screen-switch/package.mk

This file was deleted.

51 changes: 0 additions & 51 deletions projects/ROCKNIX/packages/apps/screen-switch/scripts/screen_switch

This file was deleted.

1 change: 1 addition & 0 deletions projects/ROCKNIX/packages/sysutils/system-utils/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ makeinstall_target() {
mkdir -p ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/fancontrol ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/headphone_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/output_monitor ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/hdmi_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/input_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/ledcontrol ${INSTALL}/usr/bin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,6 @@ set +e
/usr/bin/mangohud_set toggle
fi
;;
(${FUNCTION_HOTKEY_BTN_BACK_EVENT}|${FUNCTION_HOTKEY_KEY_F1_EVENT})
if [ "${HOTKEY_A_PRESSED}" = true ]; then
${DEBUG} && log $0 "${FUNCTION_HOTKEY_BTN_BACK_EVENT}: Switch Screen Output"
/usr/bin/screen_switch
Comment thread
loki666 marked this conversation as resolved.
fi
;;
(${FUNCTION_HOTKEY_BTN_NORTH_EVENT})
if [ "${HOTKEY_A_PRESSED}" = true ]; then
${DEBUG} && log $0 "${FUNCTION_HOTKEY_BTN_NORTH_EVENT}: Opening Game Guide"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2025 ROCKNIX (https://github.com/ROCKNIX)
#
# Monitors external display outputs (DP, HDMI) via sway IPC and powers
# internal panels (DSI, eDP) off/on accordingly.
#
# The sway IPC subscription is used rather than udev because the actions
# (wlr-randr, swaymsg) require sway to be running and to have already
# processed the new output. Subscribing to sway output events is
# inherently synchronized with sway's internal state, avoiding the need
# for retry logic after a kernel hotplug uevent.

. /etc/profile

# Exit if this device has no external display connectors at all
ls /sys/class/drm/card*-DP-* /sys/class/drm/card*-HDMI-A-* 2>/dev/null | grep -q . || exit 0

_LAST_STATE="init"

_get_active_externals() {
wlr-randr 2>/dev/null | awk '
/^(DP|HDMI|DisplayPort)-/ { name=$1; in_ext=1; next }
/^[A-Za-z]/ { in_ext=0 }
in_ext && /Enabled: yes/ { print name }
'
}

_get_all_internals() {
wlr-randr 2>/dev/null | awk '/^(DSI|eDP|LVDS)-/ { print $1 }'
}

_apply() {
local state="internal"
[ -n "$(_get_active_externals)" ] && state="external"
[ "$_LAST_STATE" = "$state" ] && return
local prev="$_LAST_STATE"
_LAST_STATE="$state"

if [ "$state" = "external" ]; then
local ext_out
ext_out=$(_get_active_externals | head -1)
while IFS= read -r out; do
wlr-randr --output "$out" --off 2>/dev/null
done < <(_get_all_internals)
if [ -n "$ext_out" ]; then
swaymsg "[app_id=\"emulationstation\"] move output ${ext_out}" 2>/dev/null || true
fi
# Stop USB gadget: its data lanes conflict with DP Alt Mode on RK3576
systemctl is-active --quiet usbgadget && systemctl stop usbgadget
else
# Only re-enable internal panels on actual disconnect, not first-boot
if [ "$prev" != "init" ]; then
while IFS= read -r out; do
wlr-randr --output "$out" --preferred --on 2>/dev/null
done < <(_get_all_internals)
fi
fi


}

# Allow sway to finish initialising outputs before first check
sleep 3

while true; do
_apply
# Block until sway reports an output event (or 10s timeout).
# The timeout acts as a periodic retry to catch events missed when sway
# fires before finishing output configuration (e.g. boot-time hotplug).
# grep -q exits on first '"change"' match, terminating swaymsg cleanly.
timeout 10 swaymsg -t subscribe '["output"]' 2>/dev/null | grep -q '"change"' || true
sleep 0.3
done
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ if hexdump -C /sys/class/drm/card0-DP-1/edid | grep -q "Lontium"; then
echo "input \"8746:1:RetroidPocket_RDS_Touchscreen\" calibration_matrix 0 1 0 -1 0 1" >> $SWAY_HOME/config
echo 'for_window [app_id="emulationstation"] focus output DP-1' >> $SWAY_HOME/config
con="DP-1"
else
# Any other DP-1 display (AR glasses, external monitor):
# Assign workspace 1 to prefer DP-1 with DSI-1 as fallback.
# Sway automatically moves workspace 1 to DP-1 when it appears
# and back to DSI-1 when it disconnects.
echo "workspace 1 output DP-1 ${con}" >> $SWAY_HOME/config
echo 'for_window [app_id="emulationstation"] move output DP-1' >> $SWAY_HOME/config
fi

# Start the external display monitor on any device that has DP or HDMI
# hardware where the driver does not emit DRM hotplug uevents.
if ls /sys/class/drm/card*-DP-* /sys/class/drm/card*-HDMI-A-* 2>/dev/null | grep -q .; then
echo "exec /usr/bin/output_monitor" >> $SWAY_HOME/config
fi

if [ "${QUIRK_DEVICE}" = "AYANEO Pocket DS" ]; then
Expand Down
Loading