Choose style:

Author Topic: Wallpaper changer code  (Read 5081 times)

0 Members and 1 Guest are viewing this topic.

Offline rmcellig

  • Member
  • ***
  • Posts: 205
  • Karma: 13
  • New Forum User
    • View Profile
Wallpaper changer code
« on: March 29, 2014, 09: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: 1003
  • Karma: 300
  • 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, 10: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)
First lets make a desktop icon.

To create a desktop icon right click on the desktop and create a blank file. Name the file whatever you want just end it with .desktop I usually name the icon randomwallpaper.desktop

Once the file is created right click on it and open it with leafpad.

Copy and paste the following code in it

Code:

[Desktop Entry]
Version=1.0
Name=Random Wallpaper
Comment=Randomly change LXDE wallpaper.
Exec=bash -c 'pcmanfm -w "$(find /home/user_name/Pictures/Wallpaper -type f | shuf -n1)"'
Terminal=false
Type=Application
Categories=Utility;
Icon=wallpaper

Once the code is pasted close and save it.

Now I'm going to assume your new icon is on the desktop

We will place this icon in two places...

One in your autostart folder (which provide a random background on startup)

And the other one will go in your applications folder (which will provide access to it through your accessories menu.)

Open your terminal and enter these commands

cd Desktop
cp randomwallpaper.desktop ~/.config/autostart
sudo mv randomwallpaper.desktop /usr/share/applications

Open up desktop session settings (preferences menu) and make sure the Random Wallpaper icon is checked if you want it to change your desktop background on startup.

Finally and important... create a folder named Wallpapers inside your Pictures folder and place your desktop backgrounds in there..

Now whenever your computer starts it changes the background and if you want to change it yourself you can select random wallpaper from the accessories menu and it will switch it instantly.

This is an excellent no memory usage, super easy wallpaper changer solution without involving complicated scripts or heavy programs.
[close]
« Last Edit: March 29, 2014, 11:44:55 am by rjm65 »
Robert
Peppermint 9 User

Gateway Solo 9300 Pro
IBM T40

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Wallpaper changer code
« Reply #2 on: March 29, 2014, 10: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, 11: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: 1003
  • Karma: 300
  • 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, 11: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: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Wallpaper changer code
« Reply #4 on: March 29, 2014, 11: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: 205
  • Karma: 13
  • New Forum User
    • View Profile
Re: Wallpaper changer code
« Reply #5 on: March 29, 2014, 04: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: 1003
  • Karma: 300
  • 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, 04: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

  • Developer
  • Member
  • *****
  • Posts: 535
  • Karma: 75
  • Peppermint Dev
    • View Profile
    • http://kendallweaver.com
Re: Wallpaper changer code
« Reply #7 on: March 29, 2014, 05: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.
Co-Founder and CTO of Peppermint. Developer, Photographer, and spicy food lover.

Peppermint is powered by VPS.NET Cloud Servers.

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Wallpaper changer code
« Reply #8 on: March 29, 2014, 07:00:29 pm »
if it doesn't exist, create the autostart directory:
Code: [Select]
mkdir -p ~/.config/autostart
now create a .desktop ifle in there to launch the script:
Code: [Select]
gedit ~/.config/autostart/auto_wallpaper_changer.desktop
make 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.sh
if 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: 205
  • Karma: 13
  • New Forum User
    • View Profile
Re: Wallpaper changer code
« Reply #9 on: March 30, 2014, 06: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: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Wallpaper changer code
« Reply #10 on: March 30, 2014, 07: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: 205
  • Karma: 13
  • New Forum User
    • View Profile
Re: Wallpaper changer code
« Reply #11 on: March 30, 2014, 08: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: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Wallpaper changer code
« Reply #12 on: March 30, 2014, 08: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: 205
  • Karma: 13
  • New Forum User
    • View Profile
Re: Wallpaper changer code
« Reply #13 on: March 30, 2014, 08: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: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Wallpaper changer code
« Reply #14 on: March 30, 2014, 09: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