Skip to content

Commit

Permalink
review postinstall
Browse files Browse the repository at this point in the history
** Fix: can't use dpms
** Add: support of bookwarn
** Add: warn for restart OS
  • Loading branch information
bugsounet committed Oct 28, 2023
1 parent 9af42cc commit a4b66fe
Showing 1 changed file with 51 additions and 12 deletions.
63 changes: 51 additions & 12 deletions installer/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,19 @@ if [ "$screen_saver_running." != "." ]; then
gsettings set org.mate.screensaver lock_delay 0 2>/dev/null
echo " $screen_saver_running disabled"
DISPLAY=:0 mate-screensaver >/dev/null 2>&1 &
((change++))
;;
gnome-screensaver) echo 'Found: gnome screen saver'
gnome_screensaver-command -d >/dev/null 2>&1
echo " $screen_saver_running disabled"
((change++))
;;
xscreensaver) echo 'Found: xscreensaver running'
xsetting=$(grep -m1 'mode:' ~/.xscreensaver )
if [ $(echo $xsetting | awk '{print $2}') != 'off' ]; then
sed -i "s/$xsetting/mode: off/" "$HOME/.xscreensaver"
echo " xscreensaver set to off"
((change++))
else
echo " xscreensaver already disabled"
fi
Expand All @@ -97,6 +100,7 @@ if [ "$screen_saver_running." != "." ]; then
gsettings set org.gnome.desktop.screensaver lock-enabled false
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
gsettings set org.gnome.desktop.session idle-delay 0
((change++))
else
echo "gsettings screen saver already disabled"
fi
Expand All @@ -117,6 +121,7 @@ if [ $(which gsettings | wc -l) == 1 ]; then
gsettings set org.gnome.desktop.screensaver lock-enabled false
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
gsettings set org.gnome.desktop.session idle-delay 0
((change++))
else
echo "gsettings screen saver already disabled"
fi
Expand All @@ -125,26 +130,60 @@ fi
if [ -e "/etc/lightdm/lightdm.conf" ]; then
# if screen saver NOT already disabled?
echo "Found: screen saver in lightdm"
if [ $(grep 'xserver-command=X -s 0 -dpms' /etc/lightdm/lightdm.conf | wc -l) == 0 ]; then
echo "disable screensaver via lightdm.conf"
sudo sed -i '/^\[Seat:/a xserver-command=X -s 0 -dpms' /etc/lightdm/lightdm.conf
if [ $(grep 'xserver-command=X -s 0 -dpms' /etc/lightdm/lightdm.conf | wc -l) != 0 ]; then
echo "screensaver via lightdm already disabled but need to be updated"
sudo sed -i -r "s/^(xserver-command.*)$/xserver-command=X -s 0/" /etc/lightdm/lightdm.conf
((change++))
else
echo "screensaver via lightdm already disabled"
if [ $(grep 'xserver-command=X -s 0' /etc/lightdm/lightdm.conf | wc -l) == 0 ]; then
echo "disable screensaver via lightdm.conf"
sudo sed -i '/^\[Seat:/a xserver-command=X -s 0' /etc/lightdm/lightdm.conf
((change++))
else
echo "screensaver via lightdm already disabled"
fi
fi
fi
if [ -d "/etc/xdg/lxsession/LXDE-pi" ]; then
currently_set=$(grep -m1 '\-dpms' /etc/xdg/lxsession/LXDE-pi/autostart)
currently_set_old=$(grep -m1 '\-dpms' /etc/xdg/lxsession/LXDE-pi/autostart)
currently_set=$(grep -m1 '\xset s off' /etc/xdg/lxsession/LXDE-pi/autostart)
echo "Found: screen saver in lxsession"
if [ "$currently_set." == "." ]; then
echo "disable screensaver via lxsession"
# turn it off for the future
sudo su -c "echo -e '@xset s noblank\n@xset s off\n@xset -dpms' >> /etc/xdg/lxsession/LXDE-pi/autostart"
# turn it off now
export DISPLAY=:0; xset s noblank;xset s off;xset -dpms
if [ "$currently_set_old." != "." ]; then
echo "lxsession screen saver already disabled but need to updated"
sudo sed -i "/^@xset -dpms/d" /etc/xdg/lxsession/LXDE-pi/autostart
export DISPLAY=:0; xset s noblank;xset s off
((change++))
else
echo "lxsession screen saver already disabled"
if [ "$currently_set." == "." ]; then
echo "disable screensaver via lxsession"
# turn it off for the future
sudo su -c "echo -e '@xset s noblank\n@xset s off' >> /etc/xdg/lxsession/LXDE-pi/autostart"
# turn it off now
export DISPLAY=:0; xset s noblank;xset s off
((change++))
else
echo "lxsession screen saver already disabled"
fi
fi
fi

if [ -e "$HOME/.config/wayfire.ini" ]; then
echo "Found: screen saver in wayland"
current_set=$(grep -m1 "dpms_timeout" $HOME/.config/wayfire.ini | awk '{print $3}')
if [ "$current_set" != 0 ]; then
echo "disable screensaver via wayfire.ini"
sed -i -r "s/^(dpms_timeout.*)$/dpms_timeout = 0/" $HOME/.config/wayfire.ini
((change++))
else
echo "wayland screen saver already disabled"
fi
fi

if [[ "$change" -gt 0 ]]; then
echo
Installer_warning "[WARN] There is some change for disable screen saver"
Installer_warning "[WARN] Please, don't forget to reboot your OS for apply the new configuration!"
fi
Installer_success "Done"
echo

Expand Down

6 comments on commit a4b66fe

@sdetweil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the wayfire.ini on my pi5 doesn't have anything about dpms in it.

[command]
repeatable_binding_volume_up = KEY_VOLUMEUP
command_volume_up = wfpanelctl volumepulse volu
repeatable_binding_volume_down = KEY_VOLUMEDOWN
command_volume_down = wfpanelctl volumepulse vold
binding_mute = KEY_MUTE
command_mute = wfpanelctl volumepulse mute
binding_menu = <super>
command_menu = wfpanelctl smenu menu
binding_terminal = <ctrl> <alt> KEY_T
command_terminal = lxterminal
binding_bluetooth = <ctrl> <alt> KEY_B
command_bluetooth = wfpanelctl bluetooth menu
binding_netman = <ctrl> <alt> KEY_W
command_netman = wfpanelctl netman menu
binding_grim = KEY_SYSRQ
command_grim = grim
binding_orca = <ctrl> <alt> KEY_SPACE
command_orca = gui-pkinst orca reboot
binding_quit = <ctrl> <alt> KEY_DELETE
command_quit = lxde-pi-shutdown-helper
binding_power = KEY_POWER
command_power = pwrkey

[input-device:generic ft5x06 (79)]
output = DSI-1

[input-device:generic ft5x06 (80)]
output = DSI-1

[input-device:FT5406 memory based driver]
output = DSI-1

[input]
xkb_options=
xkb_model=pc105
xkb_layout=us
xkb_variant=

@bugsounet
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from there

that why i search to add this:

[idle]
dpms_timeout=0

@bugsounet
Copy link
Owner Author

@bugsounet bugsounet commented on a4b66fe Jan 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after (manual) modification of wayfire.ini file (pi4)

mine is now this:

[command]
repeatable_binding_volume_up=KEY_VOLUMEUP
command_volume_up=wfpanelctl volumepulse volu
repeatable_binding_volume_down=KEY_VOLUMEDOWN
command_volume_down=wfpanelctl volumepulse vold
binding_mute=KEY_MUTE
command_mute=wfpanelctl volumepulse mute
binding_menu=<super>
command_menu=wfpanelctl smenu menu
binding_terminal=<ctrl> <alt> KEY_T
command_terminal=lxterminal
binding_bluetooth=<ctrl> <alt> KEY_B
command_bluetooth=wfpanelctl bluetooth menu
binding_netman=<ctrl> <alt> KEY_W
command_netman=wfpanelctl netman menu
binding_grim=KEY_SYSRQ
command_grim=grim
binding_orca=<ctrl> <alt> KEY_SPACE
command_orca=gui-pkinst orca reboot
binding_quit=<ctrl> <alt> KEY_DELETE
command_quit=lxde-pi-shutdown-helper
binding_power=KEY_POWER
command_power=pwrkey

[input-device:10-0038 generic ft5x06 (79)]
output=DSI-1

[input-device:6-0038 generic ft5x06 (79)]
output=DSI-1

[input-device:4-0038 generic ft5x06 (79)]
output=DSI-2

[input-device:10-0038 generic ft5x06 (00)]
output=DSI-1

[input-device:6-0038 generic ft5x06 (00)]
output=DSI-1

[input-device:4-0038 generic ft5x06 (00)]
output=DSI-2

[input]
xkb_options=
xkb_model=pc105
xkb_layout=fr
xkb_variant=

kb_repeat_delay=400
kb_repeat_rate=40
mouse_cursor_speed=0
left_handed_mode=false

[idle]
dpms_timeout=0

With this modification, we are able to use dpms for turn off screen and disable timeout

But we have to check idle section (exist or not)

  • if exist: add (or modify) dpms_timeout=0
  • if don't exist: add [idle] section AND add dpms_timeout=0

@sdetweil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I didn't get that Info from your prior message.

will examine this afternoon
have grandsons this morning

@sdetweil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with these two searches we can find if and where each line is
idle

grep -n  -i "\[idle\]" .config/wayfire.ini 
40:[idle]

dpms

grep -n  -i "dpms" .config/wayfire.ini 
41:dpms_timeout=0

if wc -l >0 then that search found something

if both are >0 then we found both

echo result | awk -F: '{print $1}'
will give us the line number for each

if dpms line number is > idle line number its is after
and diff of line numbers tells us how far apart they are

thinking they should be together

grep -A1 "[idle]" .config/wayfire.ini

could give us the 2 lines, from the [idle\ line plus 1
grep -B1 -i dpms .config/wayfire.ini
will do the same from the dpms line back 1

if neither is present add both
if idle is present add dpms on line after idle
if dpms present add [idle] on line before dpms
if both present, then change dpms value ?????

is that right?

@bugsounet
Copy link
Owner Author

@bugsounet bugsounet commented on a4b66fe Jan 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if dpms present add [idle] on line before dpms

should never happen except... user forget to add [idle] section
in this case maybe ... copy the dpms value into the proper section ?
if you add directly [idle] section one line defore dpms, it's dangerous... because other values (if exist) will be in [idle] section

Other is fine :)

Please sign in to comment.