Help! My script isn’t running the command to set the wallpaper in Hyprland.

0
5
Asked By CuriousCoder42 On

I'm having trouble with a command in my Bash script that's supposed to set the wallpaper in Hyprland after it starts up. Here's the relevant part of my script:

```bash
for i in "$@"; do
case $i in
-W | --Wallpaper )
WALLPAPER="$2"
Hyprland & # Start Hyprland.
sleep 30s && # Time to let Hyprland initialize.
alacritty --hold -e set-wal -w "$WALLPAPER" -c -n # Apply System Theme and Wallpaper.
shift
;;
...
esac
shift
done
```

I think it might not be finding a graphical interface even after Hyprland starts. Anyone know what's going wrong?

5 Answers

Answered By ScriptSavvy On

I noticed you have `&&` after `sleep`, but nothing follows it. This might be causing the next command to run too early. Try just using `sleep 30s` without the `&&` and see if that helps.

CuriousCoder42 -

I updated it, but it still doesn’t seem to work.

Answered By CodingConnoisseur On

I think the problem is that you're executing commands outside of Hyprland. For graphical apps like Alacritty to work right, they need to be launched from inside Hyprland. You might want to set that command in your Hyprland config instead:

```bash
exec-once = set-wal -w /path/to/wallpaper.png -c -n
```

Also, consider simplifying your network commands using shell aliases to avoid the complexity of your script.

Answered By TechNerd99 On

That startup command looks a bit odd for running things in Hyprland. Try changing the `alacritty` line to log the output instead:

```bash
set-wal -w "$WALLPAPER" -c -n &> $HOME/my_log.txt
printf '%sn' "EXIT CODE: $?" >> $HOME/my_log.txt
```

Then after you restart, check the log with `cat $HOME/my_log.txt`. That should give you more clues!

CuriousCoder42 -

I tried that and got this in the log: "Socket file not found. Are you sure swww-daemon is running?" EXIT CODE: 1. So it seems even with a 30-second sleep, swww won't initialize.

Answered By ShellShocker On

You're right about needing the environment variable. For `alacritty` to connect, you might set up a symlink just before launching Hyprland:

```bash
ln -s "$WALLPAPER" "$XDG_RUNTIME_DIR/current-wallpaper"
```

Then, have `set-wal` execute from your Hyprland config using the symlink. That should fix the issue!

Answered By NetworkNinja On

Have you tested that command manually? Just run the `set-wal` line in your terminal after Hyprland starts and see if it works without issues.

CuriousCoder42 -

Yeah, manually it works! It changes the wallpaper and applies the colors fine.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.