Deepin V20 随机设置桌面壁纸
Tofloor
poster avatar
aijuntao
deepin
2020-09-25 06:59
Author
  1. #!/bin/bash

  2. # 壁纸目录
  3. dir=/etc/skel/Pictures/Wallpapers
  4. # 壁纸文件个数
  5. count=`ls $dir | wc -w`
  6. echo $count
  7. # 生成小于壁纸个数的随机数
  8. ssj=$((RANDOM % $count))
  9. echo $ssj
  10. idx=-1
  11. # 遍历壁纸目录,设置第 随机数 个文件作为壁纸
  12. for i in $dir/*; do
  13.     let idx++
  14.     if [ $idx -eq $ssj ]
  15.     then
  16.            dbus-send --dest=com.deepin.daemon.Appearance /com/deepin/daemon/Appearance --print-reply com.deepin.daemon.Appearance.SetMonitorBackground string:"eDP-1" string:"file://${i}"
  17.            exit
  18.     fi
  19. done
Copy the Code
上面一段程序主要目的是随机设置个图片作为壁纸,放到cornlab 里面,正常使用, 我来抛个砖,各位大神一起帮忙优化下,让代码看着更优雅
Reply Favorite View the author
All Replies

No replies yet