Ready. Set. Go!
This commit is contained in:
commit
f6bac59182
25
LICENSE
Normal file
25
LICENSE
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
BSD 2-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2024, apio.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
15
README.md
Normal file
15
README.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# autobg
|
||||||
|
|
||||||
|
Shell script to automatically pick a new wallpaper from a folder every so often. Made for GNOME+systemd systems.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Start by cloning the repo.
|
||||||
|
|
||||||
|
Then, edit the files to your desired settings. The default setting is to change the wallpaper every two minutes, but you may want it to be more or less frequent. To change this, edit the "OnUnitActiveSec" field in [autobg.timer](autobg.timer) and enter the number of seconds.
|
||||||
|
|
||||||
|
By default, the script picks a random wallpaper from `~/Pictures/Wallpapers`. If you'd like it to pick from a different folder, edit the path in [autobg](autobg).
|
||||||
|
|
||||||
|
You can then run the shell script [setup.sh](setup.sh). It will copy the script to `~/.local/bin` and install the files needed by systemd to run it periodically.
|
||||||
|
|
||||||
|
If you'd like to manually pick a new random wallpaper (without waiting for the timer), run `autobg` directly.
|
12
autobg
Executable file
12
autobg
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import os, random
|
||||||
|
|
||||||
|
os.chdir(os.path.join(os.path.expanduser("~"), "Pictures/Wallpapers"))
|
||||||
|
|
||||||
|
files = (file for file in os.listdir()
|
||||||
|
if os.path.isfile(os.path.join(os.getcwd(), file)))
|
||||||
|
|
||||||
|
wallpaper = random.choice(list(files))
|
||||||
|
|
||||||
|
os.system(f"gsettings set org.gnome.desktop.background picture-uri 'file:///{os.path.join(os.getcwd(),wallpaper)}'")
|
||||||
|
os.system(f"gsettings set org.gnome.desktop.background picture-uri-dark 'file:///{os.path.join(os.getcwd(),wallpaper)}'")
|
9
autobg.service
Normal file
9
autobg.service
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Set random wallpaper on login
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=HOME/.local/bin/autobg
|
||||||
|
Type=oneshot
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
9
autobg.timer
Normal file
9
autobg.timer
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Set random wallpaper every two minutes
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnActiveSec=1
|
||||||
|
OnUnitActiveSec=300
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
10
setup.sh
Executable file
10
setup.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir -p ~/.local/bin
|
||||||
|
cp ./autobg ~/.local/bin/autobg
|
||||||
|
cp ./autobg.timer ~/.config/systemd/user/autobg.timer
|
||||||
|
cp ./autobg.service ~/.config/systemd/user/autobg.service
|
||||||
|
sed -i -e "s+HOME+$HOME+g" ~/.config/systemd/user/autobg.service
|
||||||
|
systemctl --user enable --now autobg.timer
|
||||||
|
systemctl --user enable autobg.service
|
||||||
|
|
Loading…
Reference in New Issue
Block a user