Forum › Forums › Official Releases › antiX-21/22 “Grup Yorum” › bash script won’t start at boot
- This topic has 14 replies, 5 voices, and was last updated Feb 15-9:31 pm by sbis.
-
AuthorPosts
-
December 28, 2021 at 7:46 pm #73978Member
sbis
Hi, I have a problem.
The monitor randomly shutdown.After a quick search in the web I found a possible solution.
Run this command:
$ xset dpms 0 0 0 && xset -dpms && xset s off && xset s noblankThis change the result of the command “$ xset q” from this:
…
DPMS (Energy Star):
Standby: 3600 Suspend: 3600 Off: 3600
DPMS is Enabled
Monitor is Onto this:
….
DPMS (Energy Star):
Standby: 0 Suspend: 0 Off: 0
DPMS is DisabledI don’t know if this solution is the best but I have tested for a while and at the moment the monitor is still on. 😀
I want to start the command at boot so I have create a simple bash script named noblank_monitor.sh:
#!/bin/bash
xset dpms 0 0 0 && xset -dpms && xset s off && xset s noblankI simply put the line (~/./noblank_monitor.sh &) in ~/.icewm/startup and in ~/.desktop-session/startup but when the pc boot the command “$ xset q” always show this:
…
DPMS (Energy Star):
Standby: 3600 Suspend: 3600 Off: 3600
DPMS is Enabled
Monitor is OnI have tested another simple script, clock.sh:
#!/bin/bash
date >> ~/clock.txt
and it work if I put the line ~/./clock.sh &) in ~/.icewm/startup.What’s wrong?
Thanks
December 28, 2021 at 8:55 pm #73979Moderator
caprea
::It might helps troubleshooting if you start your script from terminal with ~/./noblank_monitor.sh &
Is the script executable?December 28, 2021 at 8:59 pm #73980Anonymous
::xset dpms 0 0 0 && xset -dpms && xset s off && xset s noblank &
append an ampersand character to the newly added line within the startup file, then retry
December 28, 2021 at 9:28 pm #73987Membersbis
::It might helps troubleshooting if you start your script from terminal with ~/./noblank_monitor.sh &
Is the script executable?yes, the script is executable and work fine from terminal
- This reply was modified 1 year, 4 months ago by sbis.
December 28, 2021 at 9:35 pm #73989Membersbis
::xset dpms 0 0 0 && xset -dpms && xset s off && xset s noblank &
append an ampersand character to the newly added line within the startup file, then retry
No, nothing change with & at the end
December 28, 2021 at 9:44 pm #73994Moderator
caprea
::I just tried your script and it works here on startup.No problems.
The script is in home and the line ~/./noblank_monitor.sh &
is in /home/user/.desktop-session/startupDecember 28, 2021 at 10:00 pm #73996Membersbis
::I just tried your script and it works here on startup.No problems.
The script is in home and the line ~/./noblank_monitor.sh &
is in /home/user/.desktop-session/startupI had take a look again in my /home/user/.desktop-session/startup to control what I wrote.
That’s ok but if I restart session or if I reboot “xset q” don’t change.I see always:
…
DPMS (Energy Star):
Standby: 3600 Suspend: 3600 Off: 3600
DPMS is Enabled
Monitor is OnThere’s a way to know if the script had been executed?
Thanks
December 28, 2021 at 10:14 pm #73997Moderator
caprea
::These are the last lines of the xset q command output after rebooting here
DPMS (Energy Star):
Standby: 0 Suspend: 0 Off: 0
DPMS is DisabledSo the script is running.
Edit: Strange problem. The only thing I could think of is a time problem on your side.Maybe try a sleep addition like
sleep 4 ; ~/./noblank_monitor.sh &- This reply was modified 1 year, 4 months ago by caprea.
December 28, 2021 at 10:33 pm #74001Forum Admin
Dave
::Maybe use set-screen-blank (from the control centre, menu, or termianl) to turn off the screen blanking… In the control centre it is under the session tab.
The command you are trying to setup in a startup script is the exact same command used when turning off screen blanking with set-screen-blank.On top of this, the set-screen-blank program also changes the variable SCREEN_BLANK_TIME= to 0 in ~/.desktop-session/desktop-session.conf.
Screen blanking time is set on startup in desktop-session after the startup file is run, which is likely why your command in startup is “not working”
- This reply was modified 1 year, 4 months ago by Dave.
Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown
December 29, 2021 at 9:49 am #74024Member
sybok
::Hi,
not quite sure if you find it helpful:
1) Question:
1.A) Did you suspend/hibernate the PC after the login?
1.B) If it is a notebook/netbook etc., is some power-saving utility installed and active?
I guess it could override your setting.
Then 4) would be a good solution.
1.C) Did you check all cables connecting your monitor to PC and power, to be sure they are not loosely connected?2) Test if the script did run
#!/bin/bash xset dpms 0 0 0 && xset -dpms && xset s off && xset s noblank touch /tmp/run.didThe added creates file ‘/tmp/run.did’ if it did not exist or it updates its modification time to current date.
I guess that the files in ‘/tmp/’ do not survive reboot/shutdown, thus a different way may achieve this.3) Execution in startup-file(s):
sleep 4; bash <full|relative-path-name>
I prefer the more explicit call (that works even if the file is not executable or it is located in a partition mounted without ‘exec’ attribute).4) How about a “service”?
This is a crude way as it would eat up resources; script with a loop:
– check if the setting is as desired
– if not, run the script to (un)set the blanking
– sleep#!/bin/bash while true; do # Grep the line of interest, print the 3rd column 'Disabled|Enabled' and test the value: current_setting="$(xset q | grep '^[ ]*DPMS is ' | awk ' { print $3 } ' | xargs)" if [[ "${current_setting}" =~ ^Enabled$ ]]; then bash <scriptname> echo "$(date)" >> /tmp/run.did fi sleep 60 # Sleep 60 seconds doneAnd start the service in your startup file instead
bash <service-script> &Storing the time(s) when the script was called may help you to find out (possibly by checking logs in ‘/var/log/’) what could reset the blanking.
Comment:
I once tried to use ‘<command 1> && <command 2> &’ and it did not work well.
Thus I find the call ‘bash <scriptname> &’ as a better way to do it.EDIT/Disclaimer: The script with loop is not an actual service, but I did dare to call it that way since it was inspired by the intention of starting it at boot.
- This reply was modified 1 year, 4 months ago by sybok. Reason: Added 1.C); improved the service-script and related comment
- This reply was modified 1 year, 4 months ago by sybok.
December 29, 2021 at 1:29 pm #74037Membersbis
::Hi,
not quite sure if you find it helpful:1) Question:
1.A) Did you suspend/hibernate the PC after the login?
1.B) If it is a notebook/netbook etc., is some power-saving utility installed and active?
I guess it could override your setting.
Then 4) would be a good solution.
1.C) Did you check all cables connecting your monitor to PC and power, to be sure they are not loosely connected?1.A) No, I didn’t.
1.B) My PC isn’t a notebook/netbook.
1.C) All it’s ok2) Test if the script did run
#!/bin/bash xset dpms 0 0 0 && xset -dpms && xset s off && xset s noblank touch /tmp/run.didThe added creates file ‘/tmp/run.did’ if it did not exist or it updates its modification time to current date.
I guess that the files in ‘/tmp/’ do not survive reboot/shutdown, thus a different way may achieve this.Thanks, I’ll use this tip in the future.
3) Execution in startup-file(s):
sleep 4; bash <full|relative-path-name>
I prefer the more explicit call (that works even if the file is not executable or it is located in a partition mounted without ‘exec’ attribute).For now I follow the Dave’s hint.
If the problem persist I try yours.4) How about a “service”?
This is a crude way as it would eat up resources; script with a loop:
– check if the setting is as desired
– if not, run the script to (un)set the blanking
– sleep#!/bin/bash while true; do # Grep the line of interest, print the 3rd column 'Disabled|Enabled' and test the value: current_setting="$(xset q | grep '^[ ]*DPMS is ' | awk ' { print $3 } ' | xargs)" if [[ "${current_setting}" =~ ^Enabled$ ]]; then bash <scriptname> echo "$(date)" >> /tmp/run.did fi sleep 60 # Sleep 60 seconds doneAnd start the service in your startup file instead
bash <service-script> &Storing the time(s) when the script was called may help you to find out (possibly by checking logs in ‘/var/log/’) what could reset the blanking.
Comment:
I once tried to use ‘<command 1> && <command 2> &’ and it did not work well.
Thus I find the call ‘bash <scriptname> &’ as a better way to do it.Thanks
December 29, 2021 at 1:39 pm #74038Membersbis
::…
3) Execution in startup-file(s):
sleep 4; bash <full|relative-path-name>
I prefer the more explicit call (that works even if the file is not executable or it is located in a partition mounted without ‘exec’ attribute).
…
Comment:
I once tried to use ‘<command 1> && <command 2> &’ and it did not work well.
Thus I find the call ‘bash <scriptname> &’ as a better way to do it.For testing I add in my /home/user/.desktop-session/startup
sleep 5; bash ~/./noblank_monitor.sh &and it work fine now.
December 29, 2021 at 2:02 pm #74040Forum Admin
Dave
::Does the control centre program (set-screen-blank) not work / does it have a bug?
Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown
December 29, 2021 at 2:56 pm #74042Membersbis
::Does the control centre program (set-screen-blank) not work / does it have a bug?
I don’t know.
I put the bash script apart.
For now I try (set-screen-blank) and in the next days I see what happen.February 15, 2022 at 9:31 pm #77480Membersbis
::Hi,
in two months with “set-screen-blank” option enabled, the monitor has never turned off.Thank’s all
-
AuthorPosts
- You must be logged in to reply to this topic.