Author Topic: Wallpaper changer code  (Read 6049 times)

Offline rmcellig

  • Member
  • ***
  • Posts: 207
  • Karma: 14
  • New Forum User
    • View Profile
Wallpaper changer code
« on: March 29, 2014, 06:58:51 am »
I'm running Peppermint 4 and am looking for a simple one line of code I can put in my Gnome-schedule that would allow me to change my wallpaper at pre-determined times.  Anyone out there know of such a thing that works well in Peppermint? I don't want to use apps like Variety or Wally for example. Just something simple.

Thanks!

Offline rjm65

  • Veteran
  • ****
  • Posts: 1029
  • Karma: 313
  • I have Peppermint Fresh Breath. :P
    • View Profile
  • Peppermint version(s): Win-98 /Win-7/ Peppermint 9
Re: Wallpaper changer code
« Reply #1 on: March 29, 2014, 07:20:37 am »
I'm running Peppermint 4 and am looking for a simple one line of code I can put in my Gnome-schedule that would allow me to change my wallpaper at pre-determined times.  Anyone out there know of such a thing that works well in Peppermint? I don't want to use apps like Variety or Wally for example. Just something simple.

Thanks!
I use this one on peppermint 3 and it works just fine...
It changes wallpaper at boot up and also creates an icon in your start menu which you can add to your task bar to manually change them with a single click...
Spoiler (click here to view / hide)
[close]
« Last Edit: March 29, 2014, 08:44:55 am by rjm65 »
Robert
Peppermint 9 User

Gateway Solo 9300 Pro
IBM T40

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: Wallpaper changer code
« Reply #2 on: March 29, 2014, 07:59:24 am »
Dunno about a single line of code, but here's a script that will change your wallpaper every 30mins for a randomly selected one from your ~/Pictures directory.

Code: [Select]
#!/bin/bash
## Auto Wallpaper Changer
n=10
while [ $n -le 10 ]
do
sleep 30m &&
NUMBER=$[ ( $RANDOM % 81 ) + 1 ]
pcmanfm -w "$(find /home/YOUR_USERNAME/Pictures -type f | shuf -n1)"
done
(be sure to change "YOUR_USERNAME" to your actual Peppermint username)

Just call it something like auto_wallpaper_changer.sh .. make it executable .. and run it from autostart

Obviously you can adjust the sleep time to whatever you like, and/or the path to the directory that contains your wallpapers.



You can terminate it at any time with:
Code: [Select]
sudo killall auto_wallpaper_changer.sh
« Last Edit: March 29, 2014, 08:21:19 am by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline rjm65

  • Veteran
  • ****
  • Posts: 1029
  • Karma: 313
  • I have Peppermint Fresh Breath. :P
    • View Profile
  • Peppermint version(s): Win-98 /Win-7/ Peppermint 9
Re: Wallpaper changer code
« Reply #3 on: March 29, 2014, 08:22:02 am »

Obviously you can adjust the sleep time to whatever you like, and/or the path to the directory that contains your wallpapers.

I added that one to my script collection, in case someone wants them to rotate more then once at boot up....  Thanks...  :)
Robert
Peppermint 9 User

Gateway Solo 9300 Pro
IBM T40

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: Wallpaper changer code
« Reply #4 on: March 29, 2014, 08:24:36 am »
:)
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline rmcellig

  • Member
  • ***
  • Posts: 207
  • Karma: 14
  • New Forum User
    • View Profile
Re: Wallpaper changer code
« Reply #5 on: March 29, 2014, 01:52:46 pm »
Dunno about a single line of code, but here's a script that will change your wallpaper every 30mins for a randomly selected one from your ~/Pictures directory.

Code: [Select]
#!/bin/bash
## Auto Wallpaper Changer
n=10
while [ $n -le 10 ]
do
sleep 30m &&
NUMBER=$[ ( $RANDOM % 81 ) + 1 ]
pcmanfm -w "$(find /home/YOUR_USERNAME/Pictures -type f | shuf -n1)"
done
(be sure to change "YOUR_USERNAME" to your actual Peppermint username)

Just call it something like auto_wallpaper_changer.sh .. make it executable .. and run it from autostart



You mention to run it from autostart. In Peppermint 4 there doesn't seem to be an autostart folder like in 3. Probably because Openbox uses that method?

How can I call this script from Gnome-schedule?

Offline rjm65

  • Veteran
  • ****
  • Posts: 1029
  • Karma: 313
  • I have Peppermint Fresh Breath. :P
    • View Profile
  • Peppermint version(s): Win-98 /Win-7/ Peppermint 9
Re: Wallpaper changer code
« Reply #6 on: March 29, 2014, 01:57:16 pm »

You mention to run it from autostart. In Peppermint 4 there doesn't seem to be an autostart folder like in 3. Probably because Openbox uses that method?

How can I call this script from Gnome-schedule?
Did you try /etc/xdg/autostart
I believe there is an autostart there, and also one in your home folder under .config/autostart
Robert
Peppermint 9 User

Gateway Solo 9300 Pro
IBM T40

Offline kendall

  • Administrator
  • Member
  • *****
  • Posts: 656
  • Karma: 133
  • Co-Founder
    • View Profile
Re: Wallpaper changer code
« Reply #7 on: March 29, 2014, 02:21:32 pm »
Yes, there is still an autostart file in /etc/xdg for lxsession to use regardless of what window manager it's using. The specific location depends on which profile you launch lxsession with.
Peppermint is powered by VPS.NET Cloud Servers.

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: Wallpaper changer code
« Reply #8 on: March 29, 2014, 04:00:29 pm »
if it doesn't exist, create the autostart directory:
Code: [Select]
mkdir -p ~/.config/autostartnow create a .desktop ifle in there to launch the script:
Code: [Select]
gedit ~/.config/autostart/auto_wallpaper_changer.desktopmake it read:-
Code: [Select]
[Desktop Entry]
Type=Application
Name=Auto Wallpaper Changer
Comment=Change wallpaper every 30mins
Exec=bash -c "/full/path/to/auto_wallpaper_changer.sh"
Icon=wallpaper
Terminal=false
Categories=Utility;
(obviously you need to change the path in the "Exec=" line)

SAVE the file .. log off/on to test.



you can check if the script is running with:
Code: [Select]
ps aux | grep [a]uto_wallpaper_changer.shif you get any output, it's running.
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline rmcellig

  • Member
  • ***
  • Posts: 207
  • Karma: 14
  • New Forum User
    • View Profile
Re: Wallpaper changer code
« Reply #9 on: March 30, 2014, 03:50:47 am »
Herei s what I have done. Does this look OK?

When I selected Attachments and other options, I couldn't figure out how to add my screenshot to this post. So, here is the code:

This resides in /home/randy/Pictures

Code: [Select]
#!/bin/bash
## Auto Wallpaper Changer
n=10
while [ $n -le 10 ]
do
sleep 10m &&
NUMBER=$[ ( $RANDOM % 81 ) + 1 ]
pcmanfm -w "$(find /home/randy/Pictures/wallpaper -type f | shuf -n1)"
done

This resides in /home/randy/.config/autostart

Code: [Select]
[Desktop Entry]
Type=Application
Name=Auto Wallpaper Changer
Comment=Change wallpaper every 10mins
Exec=bash -c "/home/randy/Pictures/auto_wallpaper_changer.sh"
Icon=wallpaper
Terminal=false
Categories=Utility;

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: Wallpaper changer code
« Reply #10 on: March 30, 2014, 04:42:00 am »
Looks alright to me .. but did you make the script executable ?

If you reboot, what's the output from:
Code: [Select]
ps aux | grep [a]uto_wallpaper_changer.sh
and does the wallpaper change after 10mins ?
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline rmcellig

  • Member
  • ***
  • Posts: 207
  • Karma: 14
  • New Forum User
    • View Profile
Re: Wallpaper changer code
« Reply #11 on: March 30, 2014, 05:13:38 am »
I selected properties for the .sh file and made Execute for anyone. Let me see if the wallpaper changed. Haven't checked yet. Before I go on, I'd like to thank everyone in this thread for helping me. Your inctructions were detailed and concise. I really appreciate that!!! :)

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: Wallpaper changer code
« Reply #12 on: March 30, 2014, 05:25:00 am »
Open a terminal (Ctrl+Alt+T) and post the output from running this command:
Code: [Select]
ps aux | grep [a]uto_wallpaper_changer.sh
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline rmcellig

  • Member
  • ***
  • Posts: 207
  • Karma: 14
  • New Forum User
    • View Profile
Re: Wallpaper changer code
« Reply #13 on: March 30, 2014, 05:30:39 am »
It's working but I have a question. Where do I set the time for it to change? Is it where it says sleep? What does n=10 mean?

Code: [Select]
#!/bin/bash
## Auto Wallpaper Changer
n=10
while [ $n -le 10 ]
do
sleep 30m &&
NUMBER=$[ ( $RANDOM % 81 ) + 1 ]
pcmanfm -w "$(find /home/YOUR_USERNAME/Pictures -type f | shuf -n1)"
done

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: Wallpaper changer code
« Reply #14 on: March 30, 2014, 06:19:47 am »
That's twice now I've asked for that output and you've not responded .. are you having problems running the command ?

Quote
Where do I set the time for it to change?

with the

sleep 30m

That's currently set for every 30mins
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec