使用 bash 自动选择壁纸时“没有这样的文件或目录” - NixOS

问题描述 投票:0回答:1
#! /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

此代码返回此错误:

Error: "failed to open image: No such file or directory (os error 2)"

在错误测试方面,我试图回应:

swww img "$Wallpaper_Dir'$chosen'"
它返回
swww img ~/.config/hypr/Wallpapers/'Chill Study.jpg'
看起来不错,请注意,我在代码中使用完整路径而不是
~
,想知道是否有人可以解释为什么

bash nixos
1个回答
0
投票
~/.config/hypr/Wallpapers/'Chill Study.jpg'

您的评论与以下内容不同:

"~/.config/hypr/Wallpapers/'$chosen'"

来自您的代码。

© www.soinside.com 2019 - 2024. All rights reserved.