【问题标题】:How to change the desktop wallpaper on linux from within a shell/bash script如何从 shell/bash 脚本中更改 linux 上的桌面壁纸
【发布时间】:2016-03-20 00:54:02
【问题描述】:

我想在 Linux 上通过 shell/bash 脚本更改壁纸(使用其完整路径更改为特定文件)。

我已经找到了几种方法(见下文)来做到这一点 - 但这些方法并不适用于所有桌面环境。

a) 使用 gnome-settings-daemon / gsettings:

gsettings set org.gnome.desktop.background picture-uri   file://$fullPathToMyImage

b) 使用 gconftool-2

gconftool-2 --type=string --set /desktop/gnome/background/picture_filename $fullPathToMyImage

c) 使用 feh

feh --bg-scale $fullPathToMyImage

我现在正在寻找其他方法(而 Gnome 似乎涵盖了 a、b 和 c) - 更适合所有桌面环境(和所有 linux 发行版)。

到目前为止,我至少缺少 KDE4/5 和 XFCE 的方法

类似帖子:Shell script changing desktop wallpaper

【问题讨论】:

  • 我假设您已经意识到这一点,但不会有任何单一的方法适用于所有桌面环境(尽管您当然可以涵盖大多数主要环境)。
  • @forkrul:是的,我已经假设了 - 但感谢您指出;)。我只是希望收集/了解/找到所有主要的,以便在我的脚本中的某种案例陈述中提供一个好的解决方案

标签: linux bash shell kde xfce


【解决方案1】:

至于 xfce 你可以使用这个命令:

 xfconf-query -c xfce4-desktop -p $xfce_desktop_prop_prefix/workspace1/last-image -s /path/to/file

还有有用的设置图像例如缩放

xfconf-query -c xfce4-desktop -p $xfce_desktop_prop_prefix/workspace1/image-style -s 5

你可以在我的脚本中看到我是如何做到的 - https://github.com/yatsenko-ihor/himawari8-wallaper/blob/master/himawari8_wallaper.sh

【讨论】:

  • 感谢您的意见。在以下输出中为我提供结果:通道“xfce4-desktop”上不存在属性“/workspace1/last-image”。如果要创建新属性,请使用 --create 选项。
猜你喜欢
  • 1970-01-01
  • 2017-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多