Skip to content

Commit

Permalink
Adding backend and fill options
Browse files Browse the repository at this point in the history
  • Loading branch information
anufrievroman committed Aug 10, 2023
1 parent 21e9f24 commit 8592fee
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 16 deletions.
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ GUI wallpaper setter for both Wayland and X11 window managers that works as a fr

## Features

- Support for GIF animations (with `swww` backend)
- Support for GIF animations (with `swww`)
- GUI wallpaper selection
- Works on both Wayland and X11
- Restores wallpaper on launch of your WM
- Works on both Wayland (with `swaybg` or `swww`) and X11 (with `feh`)
- Restores wallpaper at launch of your WM

## Installation

You need to install at least one of the backends and the waypaper, which works as a frontend.
You need to install at least one of the backends and Waypaper, which works as a frontend.

### 1. Install backend
### 1. Install a backend

Install a preferred backend from your package manager: [swaybg](https://github.com/swaywm/swaybg) or [swww](https://github.com/Horus645/swww) on Wayland or [feh](https://github.com/derf/feh) on x11. You can also install and test all of them.

- [swaybg](https://github.com/swaywm/swaybg) - the wayland backend that supports only static images.
- [swww](https://github.com/Horus645/swww) - the wayland backend that also supports animated GIFs.
- [feh](https://github.com/derf/feh) - the x11 backend that supports static images.

### 2. Install waypaper (from PyPi)
### 2. Install Waypaper (from PyPi)

`pipx install waypaper`

If `pipx` is not found, you first need to install `pipx` from your package manager, it's sometimes called `python-pipx`.

### 2. Install waypaper (from AUR)
### 2. Install Waypaper (from AUR)

[waypaper-git](https://aur.archlinux.org/packages/waypaper-git) package is available in AUR, thanks to *metak*. If you are on arch-based system, you can install it as:
[waypaper-git](https://aur.archlinux.org/packages/waypaper-git) package is available in AUR, thanks to *metak*. So, on arch-based system, you can install it as:

`yay -S waypaper-git`

Expand All @@ -42,7 +42,7 @@ If `pipx` is not found, you first need to install `pipx` from your package manag

## Usage

`waypaper` command will run GUI application.
`waypaper` command will run GUI application. Make sure to choose the backend that you installed.

To restore your wallpaper at launch, add `waypaper --restore` to your startup config. For example:

Expand All @@ -53,12 +53,22 @@ To restore your wallpaper at launch, add `waypaper --restore` to your startup co
**In Sway or I3**

`exec waypaper --restore`

### Options

`--restore` - sets the last chosen wallpaper. Useful at launch of the window manager.

`--backend=XXX` - specifies which backend to use, which can be either `swaybg`, `swww`, or `feh`. Useful if you use waypaper on both wayland and x11 on the same machine. By default, last used backend is used.

`--fill=XXX` - specifies filling type, which can be eiher `fill`, `stretch`, `fit`, `center`, or `tile`.

## Troubleshooting

- If wallpaper does not change, make sure that `swaybg` or `swww` is installed.
- If application does not run, make sure to install gobject library (it might be called `python-gobject` or `python3-gi` in your package manager). Although it is supposed to be installed automatically with the package.
- Please understand that not all backends work on all system, choose the right one for you and stick to it.
- If you use different WMs on the same system, specify the backend when you restore the wallpaper at launch. For example: `
`waypaper --restore --backend=feh`

## Roadmap

Expand Down
2 changes: 1 addition & 1 deletion waypaper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from waypaper.config import cf


__version__ = "1.3"
__version__ = "1.4"


def run():
Expand Down
12 changes: 6 additions & 6 deletions waypaper/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from waypaper.changer import change_wallpaper
from waypaper.config import cf
from waypaper.options import FILL_OPTIONS, BACKEND_OPTIONS


def get_image_paths(root_folder, include_subfolders=False, depth=None):
Expand Down Expand Up @@ -67,19 +68,18 @@ def __init__(self):
# Create a backend dropdown menu:
# self.backend_option_label = Gtk.Label(label="")
self.backend_option_combo = Gtk.ComboBoxText()
options = ["swaybg", "swww", "feh"]
for option in options:
for option in BACKEND_OPTIONS:
self.backend_option_combo.append_text(option)
active_num = options.index(cf.backend)
active_num = BACKEND_OPTIONS.index(cf.backend)
self.backend_option_combo.set_active(active_num)
self.backend_option_combo.connect("changed", self.on_backend_option_changed)

# Create a fill option dropdown menu:
# self.fill_option_label = Gtk.Label(label="")
self.fill_option_combo = Gtk.ComboBoxText()
options = ["Fill", "Stretch", "Fit", "Center", "Tile"]
for option in options:
self.fill_option_combo.append_text(option)
for option in FILL_OPTIONS:
capitalized_option = option[0].upper() + option[1:]
self.fill_option_combo.append_text(capitalized_option)
self.fill_option_combo.set_active(0)
self.fill_option_combo.connect("changed", self.on_fill_option_changed)

Expand Down
23 changes: 23 additions & 0 deletions waypaper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import configparser
import pathlib
import getopt
import sys
import os

from waypaper.options import FILL_OPTIONS, BACKEND_OPTIONS

class Config:
"""User configuration loaded from the config.ini file"""
Expand Down Expand Up @@ -61,6 +64,25 @@ def save(self):
config.write(configfile)


def read_parameters_from_user_arguments(self):
"""Read user arguments that were provided at the run. This values take priority over config.ini"""
try:
opts, _ = getopt.getopt(sys.argv[1:],"",["backend=", "restore", "fill="])
for opt, arg in opts:

# Reading backend:
if opt in '--backend' and arg in BACKEND_OPTIONS:
self.backend = arg

# Reading fill option:
if opt in '--fill' and arg in FILL_OPTIONS:
self.fill_option = arg

except getopt.GetoptError as e_message:
print("Invalid user arguments. %s", e_message)
pass


cf = Config()

# Create config folder:
Expand All @@ -73,3 +95,4 @@ def save(self):

# Read config file:
cf.read()
cf.read_parameters_from_user_arguments()
2 changes: 2 additions & 0 deletions waypaper/options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BACKEND_OPTIONS = ["swaybg", "swww", "feh"]
FILL_OPTIONS = ["fill", "stretch", "fit", "center", "tile"]

0 comments on commit 8592fee

Please sign in to comment.