Artix Linux Forum

Artix Linux => Software development => Topic started by: wanwalk on 04 February 2025, 14:15:57

Title: Help with script to change wallpaper just before shutdown ?
Post by: wanwalk on 04 February 2025, 14:15:57
Hi there!

I am not sure if this is the right place to post this question, but this was the only sub-forum I found with a reference to scripts.

I am running open-rc and would like to change my wallpaper (automatically) before shutdown, but  my searches result in almost exclusively systemd cases.

I will appreciate any tips, maybe links ?

Thanks in advance!
Title: Re: Help with scipt to change wallpaper just before shutdown ?
Post by: Ambie on 04 February 2025, 15:23:56
I guess you have to write openrc wallpaper_change script, put it in /etc/init.d and add it to shutdown runlevel:
Code: [Select]
sudo rc-update add wallpaper_change shutdown
Title: Re: Help with scipt to change wallpaper just before shutdown ?
Post by: wanwalk on 04 February 2025, 19:41:38
@Ambie :  Thanks for prompt answer!   

This was exactly the info I was looking for. I will now  start looking into how  to write the script.
Title: Re: Help with scipt to change wallpaper just before shutdown ?
Post by: nous on 04 February 2025, 21:10:20
This may be of help:
http://openrc.run/
Title: Re: Help with scipt to change wallpaper just before shutdown ?
Post by: wanwalk on 06 February 2025, 11:35:44
@nous: Thanks!
Title: Re: Help with scipt to change wallpaper just before shutdown ?
Post by: wanwalk on 17 February 2025, 22:35:53
Quote
posted by @Ambie: I guess you have to write openrc wallpaper_change script, put it in /etc/init.d and add it to shutdown runlevel:
 

I wrote a script and placed it in ''/etc/init.d/':
Code: [Select]
~$ less /etc/init.d/byt_wallppr.sh
#!/bin/sh
sudo  xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorLVDS1/workspace0/last-image -s /usr/share/backgrounds/xfce/paltanen.jpg

Tried to add it to shutdown runlevel:
Code: [Select]
~$  sudo rc-update add /etc/init.d/byt_wallppr.sh  shutdown
 * rc-update: service `/etc/init.d/byt_wallppr.sh' does not exist

changed perms:
Code: [Select]
$ sudo chmod 770 /etc/init.d/byt_wallppr.sh

still:
Code: [Select]
$  sudo rc-update add /etc/init.d/byt_wallppr.sh  shutdown
 * rc-update: service `/etc/init.d/byt_wallppr.sh' does not exist


Code: [Select]
~$ ls -l  /etc/init.d/byt_wallppr.sh 
-rwxrwx--- 1 root root 147 17 feb 21.56 /etc/init.d/byt_wallppr.sh

Don't know what. Is there anything wrong with my script? Have I missed any typo????????
Title: Re: Help with scipt to change wallpaper just before shutdown ?
Post by: wanwalk on 18 February 2025, 20:03:17
Wonder whether it would be better to move this thread to subforum Open-rc and in that case how does one move it?
Title: Re: Help with scipt to change wallpaper just before shutdown ?
Post by: gripped on 18 February 2025, 20:16:57
That's not a valid openrc script.

It needs to call openrc-run with the shebang a la
Code: [Select]
#!/usr/bin/openrc-run

This is one I use to call another script which sets up my fans at boot
Code: [Select]
#!/sbin/openrc-run

name=$RC_SVCNAME
command="/usr/local/bin/fanspeed"
command_args=""
pidfile="/run/${RC_SVCNAME}.pid"

depend() {
  after modules
}
It could be better I guess as openrc complains about it at shutdown but it works.
It might make more sense to pick a new wallpaper at boot rather than shutdown as openrc will be terminating things and unmounting.
You could just use rc.local to run your command if you struggle with the script.
Title: Re: Help with scipt to change wallpaper just before shutdown ?
Post by: wanwalk on 19 February 2025, 02:26:03
Quote
posted by @gripped:
It needs to call openrc-run with the shebang a la
Code: [Select]

#!/usr/bin/openrc-run

Thanks @gripped !!!!!  Had been searching for this info for a couple days!

I will try at boot.