Skip to content

Commit b18cd4b

Browse files
committed
Enable remote screen blank / wake on play
This feature applies to WebUI on locally attached display when the Target URL field is set to a remote host.
1 parent d2e7a26 commit b18cd4b

File tree

8 files changed

+23
-16
lines changed

8 files changed

+23
-16
lines changed

var/local/www/db/moode-sqlite3.db.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--
2-
-- File generated with SQLiteStudio v3.4.4 on Fri Sep 26 07:12:25 2025
2+
-- File generated with SQLiteStudio v3.4.4 on Fri Oct 3 08:00:39 2025
33
--
44
-- Text encoding used: UTF-8
55
--
@@ -588,7 +588,7 @@ INSERT INTO cfg_system (id, param, value) VALUES (54, 'camilladsp', 'off');
588588
INSERT INTO cfg_system (id, param, value) VALUES (55, 'cdsp_fix_playback', 'Yes');
589589
INSERT INTO cfg_system (id, param, value) VALUES (56, 'camilladsp_quickconv', '0,Sennheiser_HD800S_L_44100Hz_32b.raw,Sennheiser_HD800S_R_44100Hz_32b.raw,S32LE');
590590
INSERT INTO cfg_system (id, param, value) VALUES (57, 'alsa_loopback', 'Off');
591-
INSERT INTO cfg_system (id, param, value) VALUES (58, 'keyboard', 'us');
591+
INSERT INTO cfg_system (id, param, value) VALUES (58, 'local_display_url', 'http://localhost/');
592592
INSERT INTO cfg_system (id, param, value) VALUES (59, 'local_display', '0');
593593
INSERT INTO cfg_system (id, param, value) VALUES (60, 'toggle_songid', '');
594594
INSERT INTO cfg_system (id, param, value) VALUES (61, 'slsvc', '0');

www/daemon/watchdog.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,22 @@ while true; do
128128
wake_display
129129
fi
130130
else
131-
LOCAL_CARD_NUM=$(sqlite3 $SQLDB "SELECT value FROM cfg_mpd WHERE param='device'")
132-
HW_PARAMS=$(cat /proc/asound/card$LOCAL_CARD_NUM/pcm0p/sub0/hw_params)
131+
debug_log "check wake on play"
132+
LOCAL_DISPLAY_HOST=$(sqlite3 $SQLDB "SELECT value FROM cfg_system WHERE param='local_display_url'" | awk -F"/" '{print $3}')
133+
if [[ $LOCAL_DISPLAY_HOST = "localhost" ]]; then
134+
TYPE="local"
135+
CARD_NUM=$(sqlite3 $SQLDB "SELECT value FROM cfg_mpd WHERE param='device'")
136+
HW_PARAMS=$(cat /proc/asound/card$CARD_NUM/pcm0p/sub0/hw_params)
137+
else
138+
TYPE="remote"
139+
TMP=$(curl -G -S -s --data-urlencode "cmd=get_output_format" http://$LOCAL_DISPLAY_HOST/command/ | grep "Not playing")
140+
[ -z "$TMP" ] && HW_PARAMS="playing" || HW_PARAMS="closed"
141+
fi
142+
133143
if [[ $HW_PARAMS = "closed" || $HW_PARAMS = "" ]]; then
134-
debug_log "Local audio output is closed or audio device is disconnected"
144+
debug_log "$TYPE audio output is closed or audio device is disconnected"
135145
else
136-
debug_log "Local audio output is active, wake display"
146+
debug_log "$TYPE audio output is active, wake display"
137147
wake_display
138148
fi
139149
fi

www/daemon/worker.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
$timeZone = sysCmd("timedatectl show | awk -F\"=\" '/Timezone/{print $2;exit;}'");
315315
$keyboard = sysCmd("cat /etc/default/keyboard | awk -F\"=\" '/XKBLAYOUT/{print $2;exit;}'");
316316
$_SESSION['timezone'] = $timeZone[0];
317-
phpSession('write', 'keyboard', trim($keyboard[0], "\""));
317+
$_SESSION['keyboard'] = trim($keyboard[0], "\"");
318318

319319
// Store platform data
320320
$_SESSION['hdwrrev'] = getHdwrRev();
@@ -1337,9 +1337,6 @@
13371337
$param = $_SESSION['scn_cursor'] == '0' ? ' -- -nocursor' : '';
13381338
sysCmd('sed -i "/ExecStart=/c\ExecStart=/usr/bin/xinit' . $param . '" /lib/systemd/system/localdisplay.service');
13391339
// - Host address
1340-
if (!isset($_SESSION['local_display_url'])) {
1341-
$_SESSION['local_display_url'] = 'http://localhost/';
1342-
}
13431340
sysCmd("sed -i 's|--app.*|--app=\"" . $_SESSION['local_display_url'] . "\" \\\\|' " . $_SESSION['home_dir'] . '/.xinitrc');
13441341
// - Screen blank interval
13451342
if (!isset($_SESSION['scn_blank'])) {

www/inc/autocfg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function getCfgTableParams($table, $values, $prefix = '') {
125125
'System',
126126
['requires' => ['updater_auto_check'], 'handler' => 'setSessVarOnly'],
127127
['requires' => ['timezone'], 'handler' => 'setSessVarOnlySysCmd', 'cmd' => 'set-timezone %s'],
128-
['requires' => ['keyboard'], 'handler' => 'setSessVarSqlSysCmd', 'cmd' => 'set-keyboard %s'],
128+
['requires' => ['keyboard'], 'handler' => 'setSessVarOnlySysCmd', 'cmd' => 'set-keyboard %s'],
129129
['requires' => ['worker_responsiveness'], 'handler' => function($values) {
130130
$_SESSION['worker_responsiveness'] = $values['worker_responsiveness'];
131131
if ($values['worker_responsiveness'] == 'Default') {

www/per-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
if (isset($_POST['update_local_display_url'])) {
3333
if (isset($_POST['local_display_url']) && $_POST['local_display_url'] != $_SESSION['local_display_url']) {
34-
$_SESSION['local_display_url'] = $_POST['local_display_url'];
34+
phpSession('write', 'local_display_url', $_POST['local_display_url']);
3535
submitJob('local_display_url', $_POST['local_display_url'], NOTIFY_TITLE_INFO, NAME_LOCALDISPLAY . NOTIFY_MSG_SVC_RESTARTED);
3636
}
3737
}

www/sys-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@
101101

102102
if (isset($_POST['update_keyboard'])) {
103103
if (isset($_POST['keyboard']) && $_POST['keyboard'] != $_SESSION['keyboard']) {
104+
$_SESSION['keyboard'] = $_POST['keyboard'];
104105
submitJob('keyboard', $_POST['keyboard'], NOTIFY_TITLE_INFO, NOTIFY_MSG_SYSTEM_RESTART_REQD);
105-
phpSession('write', 'keyboard', $_POST['keyboard']);
106106
}
107107
}
108108

www/util/autocfg-gen.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
$currentSettings['avahi_options'] = $_SESSION['avahi_options'];
5050
$currentSettings['ready_script'] = $_SESSION['ready_script'];
5151
$currentSettings['ready_script_wait'] = $_SESSION['ready_script_wait'];
52+
$currentSettings['keyboard'] = $_SESSION['keyboard'];
5253
// Network
5354
$currentSettings['approto'] = $_SESSION['approto'];
5455
// Audio: MPD options
@@ -74,7 +75,6 @@
7475
// Mount monitor
7576
$currentSettings['fs_mountmon'] = $_SESSION['fs_mountmon'];
7677
// Local display
77-
$currentSettings['local_display_url'] = $_SESSION['local_display_url'];
7878
$currentSettings['scn_cursor'] = $_SESSION['scn_cursor'];
7979
$currentSettings['on_screen_kbd'] = $_SESSION['on_screen_kbd'];
8080
$currentSettings['scn_blank'] = $_SESSION['scn_blank'];

www/util/sysinfo.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ camilladsp=${arr[53]}
747747
cdsp_fix_playback=${arr[54]}
748748
camilladsp_quickconv=${arr[55]}
749749
alsa_loopback=${arr[56]}
750-
keyboard=${arr[57]}
750+
local_display_url=${arr[57]}
751751
[[ "${arr[58]}" = "1" ]] && local_display="On" || local_display="Off"
752752
toggle_songid=${arr[59]}
753753
[[ "${arr[60]}" = "1" ]] && slsvc="On" || slsvc="Off"
@@ -912,7 +912,6 @@ ashuffle_mode=$(moodeutl -d -gv "ashuffle_mode")
912912
ashuffle_window=$(moodeutl -d -gv "ashuffle_window")
913913
ashuffle_filter=$(moodeutl -d -gv "ashuffle_filter")
914914
ashuffle_exclude=$(moodeutl -d -gv "ashuffle_exclude")
915-
local_display_url=$(moodeutl -d -gv "local_display_url")
916915
value=$(moodeutl -d -gv "scn_cursor")
917916
[[ "$value" = "1" ]] && scn_cursor="On" || scn_cursor="Off"
918917
value=$(moodeutl -d -gv "scn_blank")
@@ -934,6 +933,7 @@ alsa_pi_audio_driver=$(moodeutl -d -gv "pi_audio_driver")
934933
crossfeed=$(moodeutl -d -gv crossfeed)
935934
value=$(moodeutl -d -gv peppy_display_type)
936935
[[ "$value" = "meter" ]] && peppy_display_type="Meter" || peppy_display_type="Spectrum"
936+
keyboard=$(moodeutl -d -gv "keyboard")
937937

938938
# Network settings
939939
RESULT=$(sqlite3 $SQLDB "select * from cfg_network")

0 commit comments

Comments
 (0)