简体   繁体   English

如何在shell / bash脚本中更改linux上的桌面墙纸

[英]How to change the desktop wallpaper on linux from within a shell/bash script

I would like to change the wallpaper (to a specific file using its full path) on linux from a shell/bash script. 我想从shell / bash脚本在linux上更改壁纸(使用其完整路径的特定文件)。

I already found several approaches (see below) to do that - but those dont work on all desktop environments. 我已经找到了几种方法(见下文) - 但那些不适用于所有桌面环境。

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

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

b) using gconftool-2 b)使用gconftool-2

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

c) using feh c)使用feh

feh --bg-scale $fullPathToMyImage

I am now searching for additional methods (while Gnome seems covered with a, b and c) - preferable for all desktop environments (and all linux distributions). 我现在正在寻找其他方法(虽然Gnome似乎用a,b和c覆盖) - 最适合所有桌面环境(以及所有Linux发行版)。

So far i am at least missing methods for KDE4/5 and XFCE 到目前为止,我至少缺少KDE4 / 5和XFCE的方法

Similar post: Shell script changing desktop wallpaper 类似的帖子: Shell脚本更改桌面壁纸

As for xfce you can use this command: 至于xfce,你可以使用这个命令:

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

And also useful set image as zoomed for example 并且还有用的设置图像缩放例如

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

You can see how I did it in my script - https://github.com/yatsenko-ihor/himawari8-wallaper/blob/master/himawari8_wallaper.sh 您可以在我的脚本中看到我是如何做到的 - https://github.com/yatsenko-ihor/himawari8-wallaper/blob/master/himawari8_wallaper.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM