Advertisement
RedTeaHacker

Script to Change Wallpaper in LXDE (Lubuntu)

Jul 25th, 2012
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.98 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. ##
  4. #
  5. # WallMorpher.rb
  6. # - RedTeaHacker
  7. #
  8. # I wrote this script for LXDE (specifically Lubuntu) because cortina,
  9. #   desktop-nova, and wallch all did not work.
  10. # To my surprise, the Ruby process had the 2nd to last lowest CPU and memory
  11. #   consumption in the System Monitor when testing this, so it shouldn't
  12. #   hurt performance at all (except for a minor spike every 10 minutes).
  13. #
  14. # Usage (start up automatically):
  15. # - chmod +x WallMorpher.rb
  16. # - sudo mv WallMorpher.rb /usr/local/bin/
  17. # - vim ~/.config/autostart/wall-morpher.desktop:
  18. #     [Desktop Entry]
  19. #     Version=1.0
  20. #     Name=Wall Morpher
  21. #     Comment=Changes wallpaper every few minutes.
  22. #     Exec=WallMorpher.rb
  23. #     Terminal=true
  24. #
  25. ##
  26.  
  27. DIR=File.expand_path('~/Pictures')
  28. SECS=60 * 10 # 10 minutes
  29.  
  30. loop do
  31.   files=Dir.glob("#{DIR}/*.*") # Inside loop so that it picks up new files
  32.   file=files[rand(files.length)]
  33.   system "pcmanfm --set-wallpaper '#{file}'"
  34.   sleep SECS
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement