Giter VIP home page Giter VIP logo

styli.sh's Introduction

Styli.sh - Wallpaper switching made easy

Styli.sh is a Bash script that aims to automate the tedious process of finding new wallpapers, downloading and switching them via the configs. Styli.sh can search for specific wallpapers from unsplash or download a random image from the specified subreddits. If you have pywal it also can set automatically your terminal colors.

Preview

Requirements

This script is made to work with feh, nitrogen, XFCE, GNOME, KDE or Sway, having one of those is a requirement.```

Install

git clone https://github.com/thevinter/styli.sh
cd styli.sh
./styli.sh

Usage

# To set a random 1920x1080 background
$ ./styli.sh

# Save the current image to ~/Pictures directory
$ ./styli.sh -sa

# To specify a desired width or height
$ ./styli.sh -w 1080 -h 720
$ ./styli.sh -w 2560
$ ./styli.sh -h 1440

# To set a wallpaper based on a search term
$ ./styli.sh -s island
$ ./styli.sh -s "sea sunset"
$ ./styli.sh -s sea -w 1080

# To get a random wallpaper from one of the set subreddits
# NOTE: The width/height/search parameters DON'T work with reddit
$ ./styli.sh -l reddit

# To get a random wallpaper from a custom subreddit
$ ./styli.sh -r <custom_reddit>
$ ./styli.sh -r wallpaperdump

# To use the builtin feh --bg options
$ ./styli.sh -b <option>
$ ./styli.sh -b bg-scale -r widescreen-wallpaper

# To add custom feh flags
$ ./styli.sh -c <flags>
$ ./styli.sh -c --no-xinerama -r widescreen-wallpaper

# To automatically set the terminal colors
$ ./styli.sh -p

# To use nitrogen instead of feh
$ ./styli.sh -n

# To update > 1 screens using nitrogen
$ ./styli.sh -n -m <number_of_screens>

# Choose a random background from a directory
$ ./styli.sh -d /path/to/dir

KDE, GNOME, XFCE & Sway

KDE, GNOME, XFCE and Sway are natively supported without the need of feh. The script currently does not allow to scale the image. To use their built-in background managers use the appropriate flag.

# GNOME
$ ./styli.sh -g

# XFCE
$ ./styli.sh -x

# KDE
$ ./styli.sh -k


# Hyprpaper (Hyprland)
$ ./styli.sh -hp

# Sway
$ ./styli.sh -y

Tips And Tricks

To set a new background every time you reboot your computer add the following to your i3/config file (or any other WM config)

exec_always path/to/script/styli.sh

To change background every hour launch the following command

crontab -e

and add the following to the opened file

@hourly path/to/script/styli.sh

Custom subreddits

To manage custom subreddits just edit the subreddits file by placing there all your desired communities, one for each newline

TODO

  • Cinnamon support
  • Remove the need for flags by reading $DESKTOP_SESSION

styli.sh's People

Contributors

backinbash avatar creator54 avatar dfcook avatar duckunix avatar enricobilla avatar gauravkumar37 avatar ma3yta avatar mfgbhatti avatar miraficus avatar nobodyinperson avatar snglth avatar thevinter avatar zero77 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

styli.sh's Issues

FEH no longer works

Since the last modification FEH no longer works...
line 381 we can read :

FEH=$(feh)

it should be written :

FEH=(feh)

crontab running not changing wall paper

Hi,
I have the following crontab:* * * * * /path/to/styli.sh -s "dark-color" -p

the colors are updated for terminal, but the wallpaper and polybar colors don't update.

If I run the /path/to/styli.sh -s "dark-color" -p directly in a terminal, it works. What could go wrong here? Thanks!!

unsplash no longer working

I am not 100% sure, but I think that unsplash has moved to only access the photos via API, so it is no long working.

Remove delay when switching wallpaper in KDE

I noticed that you have used a weird method to switch wallpaper in KDE. Which is kinda slow.

kde_cmd() {
    cp ${wallpaper} "${cachedir}/tmp.jpg"
    qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file:${cachedir}/tmp.jpg\")}"
    qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file:${wallpaper}\")}"
    sleep 5 && rm "${cachedir}/tmp.jpg"
}

I instead suggest you to use

wallpaper="${cachedir}/${RANDOM}.jpg"

and use this as the KDE function

kde_cmd() {
    qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file:${wallpaper}\")}"
}

Note that this method will pile up downloaded wallpapers inside cache directory.(which is not too bad)
But theres a way to fix this issue : https://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/

Download wallpaper folder

Hello,

Does it store the downloaded wallpapers somewhere or does it delete them each time I download a new wallpaper?

Thank you.

Systemd timer - service failed

× stylish.service - stylish wallpaper
     Loaded: loaded (/etc/systemd/system/stylish.service; static)
     Active: failed (Result: exit-code) since Sun 2021-06-06 14:17:27 +08; 25s ago
TriggeredBy: ● stylish.timer
    Process: 5066 ExecStart=/home/bo/Downloads/styli.sh/styli.sh -p (code=exited, status=1/FAILURE)
   Main PID: 5066 (code=exited, status=1/FAILURE)
        CPU: 239ms

Jun 06 14:17:27 nana styli.sh[5071]:   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
Jun 06 14:17:27 nana styli.sh[5071]:   File "/usr/lib/python3.9/site-packages/pywal/__init__.py", line 12, in <module>
Jun 06 14:17:27 nana styli.sh[5071]:     from .settings import __version__, __cache_version__
Jun 06 14:17:27 nana styli.sh[5071]:   File "/usr/lib/python3.9/site-packages/pywal/settings.py", line 21, in <module>
Jun 06 14:17:27 nana styli.sh[5071]:     CACHE_DIR = os.getenv("PYWAL_CACHE_DIR", os.path.join(HOME, ".cache", "wal"))
Jun 06 14:17:27 nana styli.sh[5071]:   File "/usr/lib/python3.9/posixpath.py", line 76, in join
Jun 06 14:17:27 nana styli.sh[5071]:     a = os.fspath(a)
Jun 06 14:17:27 nana styli.sh[5071]: TypeError: expected str, bytes or os.PathLike object, not NoneType
Jun 06 14:17:27 nana systemd[1]: stylish.service: Main process exited, code=exited, status=1/FAILURE

Error when executing styli.sh

This is the error

/home/matt/.cache/styli.sh/wallpaper.jpg: No such file or directory
feh WARNING: /home/matt/.cache/styli.sh/wallpaper.jpg does not exist - skipping
feh: No loadable images specified.
See 'feh --help' or 'man feh' for detailed usage information

MIME-Type missmatch error

Hello, I been getting this error and it's not setting the wallpaper.

Command used: /styli.sh -s "dark blue"

2021-08-01_18-29

On line 213 changing the boolean to isType=true set the wallpaper properly.

OS: Nixos
WM: i3

unable to use multiple search keywords

I want to be able to search for a phrase instead of just a single word when I'm using the -s option.
I tempered with the script because when I put quotes on my phrase it outputs something like styli.sh: line 113: [: xxx: binary operator expected. I changed line 113 to if [ ! -z "$search" ] but that didn't seem to work much more than remove the warning.

-p flag colors

not an issue but more of a feature request as I don't know other ways to do it:

is the -p flag default to dark theme? is it possible to have a light theme?

Thank you!

Bug with Ubuntu 22.04 + gnome 42 if darkmode enabled

Hello,
Stylish was not working on my Ubuntu 22.04 + GNOME 42 and Darkmode enabled.

There are now 2 ways to configure a new wallpaper with gsettings:

To set the wallpaper of the light mode:

gsettings set org.gnome.desktop.background picture-uri ''

To set the wallpaper of the dark mode:

gsettings set org.gnome.desktop.background picture-uri-dark ''

As workaround in styli.sh I've made this change :

371 gnome_cmd() {
372     #gsettings set org.gnome.desktop.background picture-uri "file://${wallpaper}"
373     gsettings set org.gnome.desktop.background picture-uri-dark "file://${wallpaper}"
374 }

Camille.

KDE multi-monitor support buggy

Hello! I just tried out styli.sh and I'm really liking it so far. It's a simple, easy script that gives me more control over my wallpaper than KDE alone.
However I've had some trouble with my multiple monitor setup. Often. it works perfectly, setting the new wallpaper on both monitors as expected. Occasionally though, it only sets the wallpaper on one monitor, leaving the other blank.

Operating System: Manjaro KDE
Plasma Version: 5.21.5
Command: ~/.styli.sh/styli.sh -k

Any idea what might be causing this?

Reddit source not working

I had to edit line 158 to make the README example "get a random wallpaper from one of the set subreddits" to work.

I replaced

mapfile -t SUBREDDITS <<<"$CONFDIR/subreddits"

with

mapfile -t SUBREDDITS <"$CONFDIR/subreddits"

Probably a typo ?

I also needed the fix provided in this issue

Error in XFCE 4.16

./styli.sh -x grep: screen.*/monitor.*image-path$: No such file or directory

Void Linux x64, Ryzen 9 mini-PC connected to HDMI monitor. Thank you for looking into this!

Not working (at least for me) anymore.

Hi,

Suddenly it is not working anymore. I used it happily for a few months on my Manjaro Xfce and now when I do

./styli.sh or any command with it I receive this:

SSL_INIT
SSL_INIT

And nothing changes...

Thank you for any suggestions.

proxy support

Not sure if it works behind proxy but adding a proxy command line arg might help or document if it does indeed work with environment proxy settings.

Code uniformity and shellcheck

As the codebase grows I think it might be worth it to ask PRs to adhere to certain guidelines around formatting and shellcode. As an example, in these two if statements, there's three different types of indentation: https://github.com/thevinter/styli.sh/blob/master/styli.sh#L202

  if [ ! -z $custom ]; then
      feh+=($custom)
  fi

  if [ ! -z $dir ]; then
    feh+=(--randomize $dir)
  else
	  feh+=("${cachedir}/wallpaper.jpg")
  fi

I wouldn't mind putting up a PR that goes through and fixes all the shellcheck issues.

Help with reddit API

I am trying to create a similar app for windows using Go language called go-wallpaper.
I am trying to download images from subreddits just like styli.sh does, but I am getting a 429 Too Many Requests error
I tried different user agents in the header, but it is not working
How to get around this?

Black screen on multiple displays KDE

Basically KDE can't find file when tries to set a wallpaper for multiple displays (probably 3+), so 1 display have wallpaper others have black screen. Fix for this:
style.sh line 349 (i'm bad at pull requests xd)
rm "${cachedir}/tmp.jpg"
to
sleep 5 && rm "${cachedir}/tmp.jpg"

Error in the subreddit option

When you try to run .

./styli.sh -n -l any subreddit

EDIT: by "any subreddit" I mean to say "any subreddit from the list of available ones".

you got this message error: MIME-Type missmatch. Downloaded file is not an image!

Sorry if this is to little information. But this is what is happening.
Hope I'm helping some way.
Congratulations for the script, really useful, wish you the best!
Keep coding!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.