Skip to content

Commit 39fafc7

Browse files
committed
WIP for HDMI screen orientation
1 parent f574f37 commit 39fafc7

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

www/daemon/worker.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,11 @@
11621162
sysCmd('sed -i "/ExecStart=/c\ExecStart=/usr/bin/xinit' . $param . '" /lib/systemd/system/localui.service');
11631163
// - Screen blank interval
11641164
sysCmd('sed -i "/xset s/c\xset s ' . $_SESSION['scnblank'] . '" ' . $_SESSION['home_dir'] . '/.xinitrc');
1165+
// Orientation
1166+
if (!isset($_SESSION['scnorient'])) {
1167+
$_SESSION['hdmi_scn_orient'] = 'landscape';
1168+
}
1169+
// TODO: code to update .xinitrc and /usr/share/X11/xorg.conf.d/40-libinput.conf
11651170
// - Disable GPU
11661171
if (!isset($_SESSION['disable_gpu_chromium'])) {
11671172
$_SESSION['disable_gpu_chromium'] = 'off';
@@ -1188,6 +1193,7 @@
11881193
workerLog('worker: Chromium ver: ' . sysCmd("dpkg -l | grep -m 1 \"chromium-browser\" | awk '{print $3}' | cut -d\":\" -f 2")[0]);
11891194
workerLog('worker: Rpi scntype: ' . $_SESSION['rpi_scntype']);
11901195
workerLog('worker: Rpi backlight: ' . $_SESSION['rpi_backlight']);
1196+
workerLog('worker: HDMI orient: ' . $_SESSION['hdmi_scn_orient']);
11911197
// HDMI enable 4k 60Hz (Pi-4 only)
11921198
if (!isset($_SESSION['hdmi_enable_4kp60'])) {
11931199
$_SESSION['hdmi_enable_4kp60'] = 'off';
@@ -3067,6 +3073,9 @@ function runQueuedJob() {
30673073
stopLocalUI();
30683074
startLocalUI();
30693075
}
3076+
case 'hdmi_scn_orient':
3077+
// TODO: code to update .xinitrc and /usr/share/X11/xorg.conf.d/40-libinput.conf
3078+
break;
30703079
case 'hdmi_enable_4kp60':
30713080
$value = $_SESSION['w_queueargs'] == 'on' ? '1' : '0';
30723081
updBootConfigTxt('upd_hdmi_enable_4kp60', $value);

www/per-config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
}
5353
}
5454

55+
if (isset($_POST['update_hdmi_scn_orient'])) {
56+
if (isset($_POST['hdmi_scn_orient']) && $_POST['hdmi_scn_orient'] != $_SESSION['hdmi_scn_orient']) {
57+
$_SESSION['hdmi_scn_orient'] = $_POST['hdmi_scn_orient'];
58+
submitJob('hdmi_scn_orient', $_POST['hdmi_scn_orient'], NOTIFY_TITLE_INFO, NAME_LOCAL_DISPLAY . NOTIFY_MSG_SVC_RESTARTED);
59+
}
60+
}
61+
5562
if (isset($_POST['update_hdmi_cec'])) {
5663
if (isset($_POST['hdmi_cec']) && $_POST['hdmi_cec'] != $_SESSION['hdmi_cec']) {
5764
phpSession('write', 'hdmi_cec', $_POST['hdmi_cec']);
@@ -208,6 +215,9 @@
208215
$_select['scnblank'] .= "<option value=\"1800\" " . (($_SESSION['scnblank'] == '1800') ? "selected" : "") . ">30 Mins</option>\n";
209216
$_select['scnblank'] .= "<option value=\"3600\" " . (($_SESSION['scnblank'] == '3600') ? "selected" : "") . ">1 Hour</option>\n";
210217

218+
$_select['hdmi_scn_orient'] .= "<option value=\"landscape\" " . (($_SESSION['hdmi_scn_orient'] == 'landscape') ? "selected" : "") . ">Landscape</option>\n";
219+
$_select['hdmi_scn_orient'] .= "<option value=\"portrait\" " . (($_SESSION['hdmi_scn_orient'] == 'portrait') ? "selected" : "") . ">Portrait</option>\n";
220+
211221
$autoClick = " onchange=\"autoClick('#btn-set-hdmi-cec');\" " . $_hdmi_cec_btn_disable;
212222
$_select['hdmi_cec_on'] .= "<input type=\"radio\" name=\"hdmi_cec\" id=\"toggle-hdmi-cec-1\" value=\"on\" " . (($_SESSION['hdmi_cec'] == 'on') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
213223
$_select['hdmi_cec_off'] .= "<input type=\"radio\" name=\"hdmi_cec\" id=\"toggle-hdmi-cec-2\" value=\"off\" " . (($_SESSION['hdmi_cec'] == 'off') ? "checked=\"checked\"" : "") . $autoClick . ">\n";

www/templates/per-config.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ <h1 class="per-config">Peripherals</h1>
9090
<span class="config-btn-after">Local Display</span>
9191
</div>
9292

93+
<label class="control-label" for="hdmi-scn-orient">HDMI Orientation</label>
94+
<div class="controls">
95+
<select id="hdmi-scn-orient" class="config-select-large" name="hdmi_scn_orient" onchange="autoClick('#btn-set-hdmi-scn-orient');" $_ctl_disabled>
96+
$_select[hdmi_scn_orient]
97+
</select>
98+
<button id="btn-set-hdmi-scn-orient" class="hide btn btn-primary btn-small config-btn-set btn-submit" type="submit" name="update_hdmi_scn_orient" value="novalue" $_ctl_disabled><i class="fa fa-solid fa-sharp fa-arrow-turn-down-left"></i></button>
99+
<a aria-label="Help" class="config-info-toggle" data-cmd="info-hdmi-scn-orient" href="#notarget"><i class="fa-regular fa-sharp fa-info-circle"></i></a>
100+
<span id="info-hdmi-scn-orient" class="config-help-info">
101+
Change between Landscape and Portrait orientation. Assumes Landscape is the native orientation of the screen.
102+
</span>
103+
</div>
104+
93105
<label class="control-label">HDMI CEC control</label>
94106
<div class="controls">
95107
<div class="toggle">

0 commit comments

Comments
 (0)