From 885017724a3b39df801f3144ca3c8841c172b31d Mon Sep 17 00:00:00 2001 From: DanjelRicci <5889576+DanjelRicci@users.noreply.github.com> Date: Fri, 10 Jul 2026 10:31:32 +0200 Subject: [PATCH 1/3] Added support for RGB Screen React mode --- common/language.c | 1 + common/language.h | 1 + common/rgb.h | 1 + module/murgb.c | 12 ++++++++++++ module/muxrgb.c | 12 ++++++++++-- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/common/language.c b/common/language.c index 39e24181..1aaf0cce 100755 --- a/common/language.c +++ b/common/language.c @@ -1533,6 +1533,7 @@ static const lang_field lang_fields[] = { {"muxrgb", LANG_OFF(muxrgb.mode_name.stick_follow), lang_specific, "Stick Follow"}, {"muxrgb", LANG_OFF(muxrgb.mode_name.preset_combo), lang_specific, "Preset Combo"}, {"muxrgb", LANG_OFF(muxrgb.mode_name.theme_supplied), lang_specific, "Theme Supplied"}, + {"muxrgb", LANG_OFF(muxrgb.mode_name.screen_react), lang_specific, "Screen React"}, {"muxrgb", LANG_OFF(muxrgb.breath_speed_name.fast), lang_specific, "Fast"}, {"muxrgb", LANG_OFF(muxrgb.breath_speed_name.medium), lang_specific, "Medium"}, {"muxrgb", LANG_OFF(muxrgb.breath_speed_name.slow), lang_specific, "Slow"}, diff --git a/common/language.h b/common/language.h index ad04d11b..e9d46ec2 100755 --- a/common/language.h +++ b/common/language.h @@ -1647,6 +1647,7 @@ struct mux_lang { char stick_follow[MAX_BUFFER_SIZE]; char preset_combo[MAX_BUFFER_SIZE]; char theme_supplied[MAX_BUFFER_SIZE]; + char screen_react[MAX_BUFFER_SIZE]; } mode_name; struct { char fast[MAX_BUFFER_SIZE]; diff --git a/common/rgb.h b/common/rgb.h index 90533cb0..ec0cd3ed 100755 --- a/common/rgb.h +++ b/common/rgb.h @@ -9,6 +9,7 @@ typedef enum { RGB_MODE_COLOUR_CYCLE = 7, RGB_MODE_RAINBOW = 8, RGB_MODE_STICK_FOLLOW = 9, + RGB_MODE_SCREEN_REACT = 10, } rgb_mode_t; typedef enum { diff --git a/module/murgb.c b/module/murgb.c index f043e126..67a02457 100755 --- a/module/murgb.c +++ b/module/murgb.c @@ -587,6 +587,18 @@ static int dispatch_restore(void) { int saved_bright_raw = st.bright_raw; rgb_colour_t col_l = st.col_l, col_r = st.col_r, col_m = st.col_m, col_f1 = st.col_f1, col_f2 = st.col_f2; + if (saved_mode == 10) { + // Screen React: the rgb_react daemon drives the LEDs itself. Start it + // if it is not already running (it records its PID and exits on its + // own when the mode changes). + system( + "P=$(cat /run/muos/rgb_react.pid 2>/dev/null); " + "{ [ -n \"$P\" ] && kill -0 \"$P\" 2>/dev/null; } || " + "setsid -f /opt/muos/script/device/rgb_react.sh /dev/null 2>&1" + ); + return 0; + } + if (saved_mode == 6) return 0; if (saved_mode == 5) saved_mode = 0; diff --git a/module/muxrgb.c b/module/muxrgb.c index 2d2c3b25..04769a7a 100755 --- a/module/muxrgb.c +++ b/module/muxrgb.c @@ -20,11 +20,11 @@ RGB_ELEMENTS #define MODES_SERIAL \ (M_BIT(RGB_MODE_OFF) | M_BIT(RGB_MODE_STATIC) | M_BIT(RGB_MODE_BREATHING) | M_BIT(RGB_MODE_PRESET_COMBO) \ - | M_BIT(RGB_MODE_THEME_SUPPLIED)) + | M_BIT(RGB_MODE_THEME_SUPPLIED) | M_BIT(RGB_MODE_SCREEN_REACT)) #define MODES_SYSFS \ (M_BIT(RGB_MODE_OFF) | M_BIT(RGB_MODE_STATIC) | M_BIT(RGB_MODE_BREATHING) | M_BIT(RGB_MODE_PRESET_COMBO) \ - | M_BIT(RGB_MODE_THEME_SUPPLIED)) + | M_BIT(RGB_MODE_THEME_SUPPLIED) | M_BIT(RGB_MODE_SCREEN_REACT)) #define MODES_JOYPAD \ (M_BIT(RGB_MODE_OFF) | M_BIT(RGB_MODE_STATIC) | M_BIT(RGB_MODE_BREATHING) | M_BIT(RGB_MODE_THEME_SUPPLIED) \ @@ -162,6 +162,9 @@ static void restore_rgb_options(void) { case 9: new_mode = RGB_MODE_STICK_FOLLOW; break; + case RGB_MODE_SCREEN_REACT: + new_mode = RGB_MODE_SCREEN_REACT; + break; default: new_mode = RGB_MODE_OFF; break; @@ -418,6 +421,7 @@ static char **build_mode_options(int *count) { {RGB_MODE_STICK_FOLLOW, 1, lang.muxrgb.mode_name.stick_follow}, {RGB_MODE_PRESET_COMBO, 1, lang.muxrgb.mode_name.preset_combo}, {RGB_MODE_THEME_SUPPLIED, 0, lang.muxrgb.mode_name.theme_supplied}, + {RGB_MODE_SCREEN_REACT, 1, lang.muxrgb.mode_name.screen_react}, }; const size_t slot_count = sizeof(slots) / sizeof(slots[0]); @@ -605,6 +609,10 @@ static void apply_mode_visibility(const int ui_mode) { show_colour_l = is_joypad; show_backend = 1; break; + case RGB_MODE_SCREEN_REACT: + show_bright = 1; + show_backend = 1; + break; case RGB_MODE_THEME_SUPPLIED: default: show_backend = 1; From f9df27b9eab3f5396dd0c9183bb8c684769f66aa Mon Sep 17 00:00:00 2001 From: DanjelRicci <5889576+DanjelRicci@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:06:11 +0200 Subject: [PATCH 2/3] Updated Screen React daemon launcher --- module/murgb.c | 14 ++++++-------- module/muxrgb.c | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/module/murgb.c b/module/murgb.c index 67a02457..27642921 100755 --- a/module/murgb.c +++ b/module/murgb.c @@ -10,6 +10,7 @@ #include #include "../common/colour.h" #include "../common/config.h" +#include "../common/exec.h" #include "../common/fileio.h" #include "../common/strutil.h" #include "../common/theme.h" @@ -588,14 +589,11 @@ static int dispatch_restore(void) { rgb_colour_t col_l = st.col_l, col_r = st.col_r, col_m = st.col_m, col_f1 = st.col_f1, col_f2 = st.col_f2; if (saved_mode == 10) { - // Screen React: the rgb_react daemon drives the LEDs itself. Start it - // if it is not already running (it records its PID and exits on its - // own when the mode changes). - system( - "P=$(cat /run/muos/rgb_react.pid 2>/dev/null); " - "{ [ -n \"$P\" ] && kill -0 \"$P\" 2>/dev/null; } || " - "setsid -f /opt/muos/script/device/rgb_react.sh /dev/null 2>&1" - ); + // Screen React: the rgb_react daemon drives the LEDs itself. It records + // its PID and exits on its own if already running or when the mode + // changes, so a redundant launch is harmless. + const char *args[] = {OPT_PATH "script/device/rgb_react.sh", NULL}; + run_exec(args, A_SIZE(args), 1, 0, NULL, NULL); return 0; } diff --git a/module/muxrgb.c b/module/muxrgb.c index 04769a7a..a5e6c027 100755 --- a/module/muxrgb.c +++ b/module/muxrgb.c @@ -162,7 +162,7 @@ static void restore_rgb_options(void) { case 9: new_mode = RGB_MODE_STICK_FOLLOW; break; - case RGB_MODE_SCREEN_REACT: + case 10: new_mode = RGB_MODE_SCREEN_REACT; break; default: From 4ecaec06c2f1a28a5e674eea9322fb728b15f51e Mon Sep 17 00:00:00 2001 From: DanjelRicci <5889576+DanjelRicci@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:09:55 +0200 Subject: [PATCH 3/3] Updated Screen React launcher comment --- module/murgb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/murgb.c b/module/murgb.c index 27642921..bf0c094d 100755 --- a/module/murgb.c +++ b/module/murgb.c @@ -589,9 +589,9 @@ static int dispatch_restore(void) { rgb_colour_t col_l = st.col_l, col_r = st.col_r, col_m = st.col_m, col_f1 = st.col_f1, col_f2 = st.col_f2; if (saved_mode == 10) { - // Screen React: the rgb_react daemon drives the LEDs itself. It records - // its PID and exits on its own if already running or when the mode - // changes, so a redundant launch is harmless. + // Screen React: the rgb_react daemon drives the LEDs itself. It keeps to + // a single instance and exits when the mode changes, so launching it on + // every restore is harmless. const char *args[] = {OPT_PATH "script/device/rgb_react.sh", NULL}; run_exec(args, A_SIZE(args), 1, 0, NULL, NULL); return 0;