Skip to content

Commit f6bf60c

Browse files
Merge pull request #7 from Tom-Hirschberger/development
Development
2 parents 97323d6 + 3765b4d commit f6bf60c

File tree

4 files changed

+130
-5
lines changed

4 files changed

+130
-5
lines changed

README.md

+95-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ To display the module insert it in the config.js file. Here is an example:
5656

5757
## Alternative commands
5858

59-
In default the module uses `vcgencmd` to control the screen. There might be situations where `vcgencmd` fails (for example with newer Raspberry Bullseye versions) and you need to find an alterative way to control the screen.
59+
In default the module uses `vcgencmd` to control the screen. There might be situations where `vcgencmd` fails (for example with newer Raspberry Bullseye or Bookworm versions) and you need to find an alterative way to control the screen.
6060

6161
You can provide your own scripts and set the paths to them with the configuration options `screenStatusCommand`, `screenOnCommand` and `screenOffCommand`.
6262

@@ -68,6 +68,16 @@ The module already provides alternative scripts in the controlScripts directory
6868

6969
This solution will work even with Raspberry OS Bullseye which uses the new "vc4-kms-v3d" graphics driver.
7070

71+
If you use Raspberry OS Bookworm you can either change your default graphics stack back to X11 instead of Wayland or you can use the `wlr-randr_control` wrapper in the next section (preferred way).
72+
73+
If you want to change back to X11 you can do it with the following steps:
74+
75+
```bash
76+
sudo raspi-config
77+
```
78+
79+
Select Option "6 - advanced options" then "A6-Wayland" and switch back to X11 (thanks to [https://forums.raspberrypi.com/viewtopic.php?t=360281#p2161288](https://forums.raspberrypi.com/viewtopic.php?t=360281#p2161288))
80+
7181
The first option of the script is the action you want the second option is optional and the port you want to use.
7282
My Raspberry 4 provides two HDMI ports which are called "HDMI-1" and "HDMI-2".
7383

@@ -130,6 +140,90 @@ In the following example the output is shut off and on but it is rotatet left:
130140

131141
Other possible rotations are "normal", "inverted", "right".
132142

143+
### wlr-randr_control
144+
145+
This solution will work even with Raspberry OS Bookworm.
146+
147+
The first option of the script is the action you want the second option is optional and the port you want to use. The third option is optional, too and can be used to set the `WAYLAND_DISPLAY` ("wayland-1" usually).
148+
149+
My Raspberry 4 provides two HDMI ports which are called "HDMI-A-1" and "HDMI-A-2".
150+
151+
You can check which port is used with the command:
152+
153+
```bash
154+
WAYLAND_DISPLAY=wayland-1 wlr-randr
155+
```
156+
157+
The output will look something like:
158+
159+
```bash
160+
HDMI-A-1 "HCD PJ402D-2 LTM12 (HDMI-A-1)"
161+
Enabled: yes
162+
Modes:
163+
640x480 px, 59.939999 Hz
164+
640x480 px, 60.000000 Hz
165+
640x480 px, 72.808998 Hz
166+
640x480 px, 75.000000 Hz
167+
720x480 px, 59.939999 Hz
168+
720x480 px, 59.939999 Hz
169+
720x480 px, 59.939999 Hz
170+
720x480 px, 60.000000 Hz
171+
720x480 px, 60.000000 Hz
172+
720x576 px, 50.000000 Hz
173+
800x600 px, 56.250000 Hz
174+
800x600 px, 60.317001 Hz
175+
800x600 px, 72.188004 Hz
176+
800x600 px, 75.000000 Hz
177+
1024x768 px, 60.004002 Hz
178+
1024x768 px, 70.069000 Hz
179+
1024x768 px, 75.028999 Hz
180+
1280x720 px, 59.939999 Hz
181+
1280x720 px, 60.000000 Hz
182+
1152x864 px, 75.000000 Hz
183+
1280x800 px, 59.995998 Hz
184+
1280x960 px, 60.000000 Hz
185+
1280x1024 px, 60.020000 Hz
186+
1920x1080 px, 59.939999 Hz
187+
1920x1080 px, 60.000000 Hz
188+
1920x1080 px, 60.000000 Hz
189+
1280x800 px, 59.910000 Hz (preferred, current)
190+
Position: 0,0
191+
Transform: normal
192+
Scale: 1.000000
193+
```
194+
195+
The first line in the output above shows that HDMI-A-1 is connected. Depending of your output you need to change the second option in the command configurtions which are following.
196+
197+
In the following example the output is simply shut off or on and no rotation is provided:
198+
199+
```json5
200+
{
201+
module: 'MMM-Screen-Powersave-Notification',
202+
config: {
203+
delay: 60,
204+
screenStatusCommand: "./modules/MMM-Screen-Powersave-Notification/controlScripts/wlr-randr_control status HDMI-A-1",
205+
screenOnCommand: "./modules/MMM-Screen-Powersave-Notification/controlScripts/wlr-randr_control on HDMI-A-1",
206+
screenOffCommand: "./modules/MMM-Screen-Powersave-Notification/controlScripts/wlr-randr_control off HDMI-A-1"
207+
}
208+
}
209+
```
210+
211+
In the following example the output is shut off and on but it is turned up-side down:
212+
213+
```json5
214+
{
215+
module: 'MMM-Screen-Powersave-Notification',
216+
config: {
217+
delay: 60,
218+
screenStatusCommand: "./modules/MMM-Screen-Powersave-Notification/controlScripts/wlr-randr_control status HDMI-A-1",
219+
screenOnCommand: "./modules/MMM-Screen-Powersave-Notification/controlScripts/wlr-randr_control 180 HDMI-A-1",
220+
screenOffCommand: "./modules/MMM-Screen-Powersave-Notification/controlScripts/wlr-randr_control off HDMI-A-1"
221+
}
222+
}
223+
```
224+
225+
The supported transformation options are: normal, 90, 180, 270, flipped, flipped-90, flipped-180, flipped-270
226+
133227
### tvservice_control
134228

135229
The `tvservice` command was an alternative to `vcgencmd` but it will **NOT** work with current installations of Raspberry OS Bullseye!

controlScripts/wlr-randr_control

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash -l
2+
export WAYLAND_DISPLAY=wayland-1
3+
port="HDMI-A-1"
4+
if [ "$2" != "" ]
5+
then
6+
port=$2
7+
fi
8+
9+
#wlr-randr --output HDMI-A-1 --transform 180 --on
10+
#wlr-randr | grep Enabled | grep -c yes
11+
12+
if [ "$1" == "on" ]
13+
then
14+
#normal,inverted,left,right
15+
wlr-randr --output $port --on
16+
$0 status $2
17+
elif [ "$1" == "off" ]
18+
then
19+
wlr-randr --output $port --off
20+
$0 status $2
21+
elif [ "$1" == "status" ] || [ "$1" == "" ]
22+
then
23+
if [ `wlr-randr | grep -i Enabled | grep -ic yes` -gt 0 ]
24+
then
25+
echo "display_power=1"
26+
else
27+
echo "display_power=0"
28+
fi
29+
else
30+
wlr-randr --output $port --transform $1
31+
fi

controlScripts/xrandr_control

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ if [ "$1" == "on" ]
1414
then
1515
#normal,inverted,left,right
1616
xrandr -display :0.0 --output $port --auto
17-
echo "display_power=1"
17+
$0 status $2
1818
elif [ "$1" == "normal" ] || [ "$1" == "inverted" ] || [ "$1" == "left" ] || [ "$1" == "right" ]
1919
then
2020
xrandr -display :0.0 --output $port --auto --rotate $1
21-
echo "display_power=1"
21+
$0 status $2
2222
elif [ "$1" == "off" ]
2323
then
2424
xrandr -display :0.0 --output $port --off
25-
echo "display_power=0"
25+
$0 status $2
2626
else
2727
if [ `xrandr -display :0.0 | grep -cE "^${port}[[:space:]]connected[^0-9]*[0-9]+[^\(]+\(.*"` -gt 0 ]
2828
then

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MMM-Screen-Powersave-Notification",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "A MagicMirror² module which controls the state of a screen and can call scripts after the screen got enabled or disabled. This module needs a other module like MMM-GPIO-Notifications which sends notifications on USER_PRESENCE.",
55
"main": "MMM-Screen-Powersave-Notification.js",
66
"dependencies": {

0 commit comments

Comments
 (0)