#! /usr/bin/env bash
Wallpaper_Dir="~/.config/hypr/Wallpapers/" #using full path in my code
chosen=$(ls $Wallpaper_Dir --ignore='Best Wallpapers.md' | rofi -dmenu -i)
swww img "$Wallpaper_Dir'$chosen'" # I added the extra quotes so that if the image name contains a space it is still able to work
this code returns this error:
Error: "failed to open image: No such file or directory (os error 2)"
in terms of bug testing I have tried to echo: swww img "$Wallpaper_Dir'$chosen'"
and it returns swww img ~/.config/hypr/Wallpapers/'Chill Study.jpg' which looks fine, note that I use the full path not ~ in my code, wondering if anyone could shed some light as to why
from your comment is not the same thing as:
from your code (expanded from
Wallpaper_Dir="~/.config/hypr/Wallpapers/" ... "$Wallpaper_Dir'$chosen'"and assuming$chosenhas the valueChill Study.jpg)In the first case,
.../'Chill Study.jpg', the's are quotes read by the shell so that the spaces are treated as literal characters in your file name, but in the second case,".../'Chill Study.jpg'", the'themselves are inside a double quoted string and so the's as well as the spaces are treated as literal characters in your file name.Please read https://mywiki.wooledge.org/Quotes to learn about quotes and there are other issues with your script too, some of which http://shellcheck.net could help you with.