The officially official Devuan Forum!

You are not logged in.

#1 Re: Hardware & System Configuration » [SOLVED] How to run a script on suspend/resume? » 2021-09-05 13:17:17

Here is a script for locking on suspend for someone whose screenlocker/saver shows desktop for a brief time before locking:

#!/bin/sh
case $1 in
	pre)
		light-locker-command -l  
		/bin/sleep 5
  	;;
        post)
                #something on resume (e.g I restart brcmfmac driver)
              	rmmod brcmfmac && modprobe brcmfmac
		/bin/sleep 5
        ;;
esac

P.S:
For it to work you have to have a screensaver running in the background (light-locker in my case)
Also change

light-locker-command -l

to whatever locking command you are using.

Hope this helps someone

#3 Re: Hardware & System Configuration » [SOLVED] How to run a script on suspend/resume? » 2021-09-04 23:36:38

Aight, I searched through gentoo forums. Basically you need to place a script in

/lib/elogind/system-sleep/

then

chmod +x

your script.

#4 Re: Hardware & System Configuration » [SOLVED] How to run a script on suspend/resume? » 2021-09-04 21:31:37

Thanks for reply and sorry for being unclear; I dont want to install pm-utils since then I will have to write a script so my laptop suspends on lid close with pm-utils instead of whatever it now uses (which would be basically the same topic I posted). Then I would have to install smth like xss-lock so it suspends after user inactivity etc etc etc.

Added clarification to the post

#5 Hardware & System Configuration » [SOLVED] How to run a script on suspend/resume? » 2021-09-04 15:00:43

xsR_head
Replies: 7

Hello, I want to run a script on suspend and resume but all the guides I find, refer me to systemd stuff (I have SysVinit). Also there are some guides referring to pm-utils, however I don’t want to install pm-utils since then I will have to write a script so my laptop suspends on lid close with pm-utils instead of whatever it now uses (which would be basically the same topic I posted). Then I would have to install smth like xss-lock so it suspends after user inactivity etc etc etc.
[SOLVED] Here is manual for elogind (look for "Hook directories"): https://manpages.debian.org/bullseye/el … .1.en.html [SOLVED]

#6 Re: Hardware & System Configuration » [SOLVED] How to run a root command on startup? » 2021-08-31 22:46:21

Aight, here is the script (I used manual for 'init-d-script' for syntax man init-d-script):

#!/bin/bash
### BEGIN INIT INFO
# Provides:          dead_XHC1
# Required-Start: $all
# Required-Stop:  
# Default-Start:  2 
# Default-Stop:   
# Short-Description: Disable wake on XHC1
# Description:       Disable wake on XHC1
#                  
### END INIT INFO
echo XHC1 > /proc/acpi/wakeup
exit 0

Then I made it executable

chmod +x /etc/init.d/dead_XHC1

Then added to the service list

sudo update-rc.d 'dead_XHC1' defaults

P.S:
Btw, this script fixes not properly working suspend on lid close for certain laptops that have issue with brcfmac driver.
You might want to play around with what device you need to disable; The enabled devices available at:

cat /proc/acpi/wakeup

Hope this will help someone, coz I spend days trying to figure out what's wrong with suspend.

#7 Re: Hardware & System Configuration » [SOLVED] How to run a root command on startup? » 2021-08-31 21:43:58

Aight, I think I figured it out, looking at other scripts. Gonna mark the question as [SOLVED] when done.

#8 Re: Hardware & System Configuration » [SOLVED] How to run a root command on startup? » 2021-08-31 21:17:48

I am pretty sure you are confusing sysvinit update-rc.d with OpenRC rc-update.
P.S I previously used OpenRC on Artix smile

#9 Hardware & System Configuration » [SOLVED] How to run a root command on startup? » 2021-08-31 20:32:15

xsR_head
Replies: 5

Hello, I want the following command to run at system startup:
echo XHC1 > /proc/acpi/wakeup
I have a sysvinit initialisation system. As far as I understand I need to create a script and place it in /etc/init.d/ then run sudo update-rc.d 'service name' defaults. I created a simple bash script:
#!/bin/bash
echo XHC1 > /proc/acpi/wakeup
but it seems that I am doing something wrong since the update-rc.d command shows error when I add the script to default run level, and the script doesn't execute for some reason.
Best regards

P.S
As far as I understand the script should be compliant to some sysvinit syntax, but I can't figure what are the exact rules.

Board footer

Forum Software