Coder Social home page Coder Social logo

dyn-wall-rs's Introduction

dyn-wall-rs

GitHub GitHub release (latest by date) Crates.io AUR

A utility to allow you to set a dynamic wallpaper and more.
Written in rust.

demo

The images used in the gif above are from the collection Lakeside by Louis Coyle.

Introduction

The aim of dyn-wall-rs is to provide users with a very simple and easy way to implement a dynamic wallpaper, as well as the setup of related things, such as the implementation of a dynamic lockscreen.

Installation

You can download the binary from the releases page but if you prefer, you can install through one of the methods listed below.
NOTE: Feh needs to be installed if you are using a Window Manager

AUR

For those using Arch Linux you can find the package on the AUR here. However, if you're using an AUR helper, the package can be installed through that. For example, If using yay, run the following command:

yay -S dyn-wall-rs

Looking for maintainer for the AUR package. Email me at [email protected] if you are interested.

Cargo

First, install rust, and then run the following command:

cargo install dyn-wall-rs

To update after installation, run:

cargo install dyn-wall-rs --force

Manual

Unix

  1. Download the latest binary from the releases page
  2. (Optional) To ensure the file you downloaded is correct and was not tampered with, do the following:
    1. Download the respective .sha256 file
    2. Run sha256sum on the .tar.gz file
    3. Compare the output of the command with the contents of the .sha256 file. If they are the same, then your file has not been tampered with
  3. Unpack the .tar.gz file by running
    tar -zxvf dyn-wall-rs.tar.gz
  4. You can now run it by running ./dyn-wall-rs in the directory the binary was unpacked. It is recommended to place the binary in your $PATH (ex. /usr/bin, which is commonly used), so you can use it from anywhere

Windows

  1. Download the latest binary from the releases page
  2. (Optional) To ensure the file you downloaded is correct and was not tampered with, do the following:
    1. Download the respective .sha256 file
    2. Open PowerShell, move to the directory contining the zip, and run
      Get-FileHash dyn-wall-rs-windows.zip -Algorithm SHA256 | Format-List
    3. Compare the sha256 the command provides with the contents of the .sha256 file. If they are the same, then your file has not been tampered with
  3. Unzip the .zip file
  4. You can now run it by opening up PowerShell and running ./dyn-wall-rs in the directory the binary was unpacked. It is recommended to place the binary in your $PATH, so you can use it from anywhere

Usage

Firstly, create a directory and place all the wallpapers you want to cycle through within the directory. Make sure that they are named in numerical order ex. first wallpaper is named 1.png, second wallpaper is named 2.png, etc.

Command Line

There are a few different ways to use dyn-wall-rs from the command line using the different flags, which are described in detail below

  • -d, --directory <DIRECTORY>
    Changes your wallpaper throughout the day with the images in the directory. If custom timings are not specified through the config file, it changes in even increments throughout the day.
    For example, if I have 12 wallpapers in my wallpaper directory, this option would change the wallpaper every 2 hours (24/12 = 2). Make sure the number of wallpapers in the directory can divide evenly into 1440 (number of minutes in a day). If it doesn't divide evenly into 1440, you may want to place custom timings in the configuration file.
    If timings are specified through the configuration file, then the wallpapers will change based on those timings. More information on custom timings can be found within the automatically created config file.

  • -p, --programs <COMMAND>
    Will send the wallpaper as an argument to the specified program(s) when the wallpaper is set to change. Using this feature, you can have your lockscreen change alongside your wallpaper. If the command includes arguments, wrap it in quotation marks.
    ex. dyn-wall-rs -d /path/to/dir/ -p "betterlockscreen -u"

    To be able to send arguments after the wallpaper argument, use !WALL to specify where the wallpaper argument is to be placed, and add the rest of the arguments. !WALL will be explanded to the path of the wallpaper to be set at the current time.
    ex. dyn-wall-rs -d /path/to/dir -p "betterlockscreen -u !WALL -b 1"

    You are also able to specifiy multiple programs to be synced with the wallpaper. Simply just insert the program names one after the other ex. dyn-wall-rs -d /path/to/dir -p "betterlockscreen -u" "echo"

  • -s, --schedule
    Prints out a schedule of the times at which the wallpaper will change depending on your settings. Use alongside the --directory option.
    Note: Cannot be set through config file.

  • -b, --backend <BACKEND>
    Uses the specified method as the backend to change the wallpaper. Type a supported DE name to use that DE's wallpaper changing command (Case insensitive), or type out a custom command to use as a backend. Similar to the program option, you can use !WALL in place of where the path of the wallpaper should be.

  • --lat <LATITUDE>
    Latitude of current location. Requires the use of the long option as well.

  • --long <LONGITUDE>
    Longitude of current location. Requires the use of the lat option as well.

  • --elevation <ELEVATION>
    Elevation of current location. Optional. Use alongside long and lat options for a more accurate sunset and sunrise reading. Expressed in meters above sea level.

Once you figure out which options you want to use and test it to make sure its working how you want it to, have the command autostart on boot.

Config File

dyn-wall-rs can also be configured through a config file. When you run the program for the first time, a config file will be created at ~/.config/dyn-wall-rs/config.toml for Unix systems, and C:\Users\<USER NAME>\AppData\Roaming\dyn-wall-rs.toml on Windows.

Through this config file, you can use the same configuration options as through the command line (except the schedule option), as well as use your own custom timings. If you would like to configure certain parameters from the config file, and others from the command line, you are able to do so. More details can be found in the automatically created config file.

Systemd Service

On systemd systems, a systemd service such as this one can be used. If installing from the AUR, this service file should already be in the right location. If you haven't installed from the AUR, you can download and move the service file to /usr/lib/systemd/system/dyn-wall-rs.service. The service can be enabled with the command systemctl --user enable dyn-wall-rs.service. If you are running the program with command line arguments, then the service file can be edited to include those arguments.

Syncing to the sun

In order to sync the changing of wallpapers according to the sunset and sunrise timings, create directories within the master directory named night and day. This will cycle through the wallpapers in the day directory if the current time is before the sunset time, and will cycle through the wallpapers in the night directory. After the directories are created and the wallpapers are placed in them, specify your latitude, longitude, and elevation (optional), and let the program do its work! You can find your coordinates through this website.

Sway

To use with sway, download the swaybg-dyn.sh script, and supply a path to it using the backend option.

dyn-wall-rs -d ~/Pictures/backgrounds/ -b ~/Scripts/swaybg-dyn.sh

Supported Desktop Environments

  • Windows
  • Gnome
  • Ubuntu
  • Pantheon
  • Deepin
  • Pop
  • KDE
  • LXDE
  • XFCE
  • Window Managers that can have their wallpaper set using Feh
  • Sway

dyn-wall-rs's People

Contributors

carniz avatar rehanzo 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

dyn-wall-rs's Issues

Don't use backend if none specified

I have multiple screens and run lxqt. I want to use custom command to set background (feh with --no-xinerama option).
If i don't specify any backend dyn-wall-rs will set the background using feh (i assume), and will do it after running any programs specified.

So in my case if i define 'program = ["feh --no-xinerama --bg-scale "]' and no backend, my background will be set to same scaled image on all screens, while if i specify 'backend = "xfce"' I'll get correct image stretched across all screens.

Since i don't use xfce i suspect that my custom program is ran first and then overriden by default feh. In my opinion the correct approach would be to not use backend if not explicitly specified, or allow for 'none' as an argument for backend.

How can I sync this with pywal?

I would like pywal to trigger every time the wallpaper changes.

wal -i "<current-wallpaper-path>" <other-options>

Is there a way to achieve this currently?

day / night folders counted as images

Using lat / long (either in config.toml or using parameters) with images in day and night folders counts those folders as if images?

(checking for schedule shows folders as images; when used with 12 pictures returns error stating 14 doesn't divide properly – wrongly counts 2+ entries)

  $ dyn-wall-rs -s Wallpapers/seq
Image: "day" Time: 12:00 a.m.
Image: "1.png" Time: 1:30 a.m.
Image: "2.png" Time: 3:00 a.m.
Image: "3.png" Time: 4:30 a.m.
Image: "4.png" Time: 6:00 a.m.
Image: "5.png" Time: 7:30 a.m.
Image: "6.png" Time: 9:00 a.m.
Image: "7.png" Time: 10:30 a.m.
Image: "8.png" Time: 12:00 p.m.
Image: "9.png" Time: 1:30 p.m.
Image: "night" Time: 3:00 p.m.
Image: "1.png" Time: 4:30 p.m.
Image: "2.png" Time: 6:00 p.m.
Image: "3.png" Time: 7:30 p.m.
Image: "4.png" Time: 9:00 p.m.
Image: "5.png" Time: 10:30 p.m.

Possibly because of min_depth being set to 2 after counting, as I understand from the source code:

    //min depth of what files should be looked at, will remain as 1 if not syncing with sun, will
    //change to 2 if syncing with sun to ignore the directory names, focusing just on the files
    let mut min_depth = 1;

this, yet:

let dir_count_night = WalkDir::new(dir_night)
    .min_depth(min_depth)
    .into_iter()
    .count();
let dir_count_day = WalkDir::new(dir_day)
    .min_depth(min_depth)
    .into_iter()
    .count();
times = sun_timings(
    lat,
    args.long.unwrap(),
    args.elevation.unwrap(),
    dir_count_day as u32,
    dir_count_night as u32,
);
min_depth = 2;

Also, not sure why day starts at 12:00 a.m. and ends at 3:00 p.m. (no matter the specified long, lat and elevation)

I installed with AUR, version 2.0.2-1, although using --version flag says 2.0.1 (issue with AUR or an oversight?)

Evenly distributed images requirement should not apply to custom configurations

I edited the config file to have 11 times, the same number as the number of images present in the images directory.

When running the command dyn-wall-rs --custom .config/wallpapers/ I get the following error message:
Cannot schedule the rotation of 11 images evenly throughout the day (the number of images should divide evenly into 1440)

My config file is as follows:

00:00
02:00
04:00
06:00
08:00
10:00
12:00
14:00
16:00
18:00
20:00

I am running dyn-wall-rs version 1.1.1 on Arch Linux, installed through the AUR. Thank you!

Edit: Markdown was poorly formatted

Internalize calculation of sunset and sunrise

At the current moment, the crate sun-times is used to obtain the timings of the sunset and sunrise. It seems like a relatively simple calculation to obtain these values, so it would be better to internalize that functionality instead of relying on an external crate.

elevation causing error in command line and config file

Firstly, is elevation in feet or meters? It's not stated anywhere and I can't find anything in your src.

Also, elevation seems to be causing this error:

Error with config file: the number of times listed in the config file does not equal the number of files in directory

This happens when I have a blank config file and lat, long, and elevation in the command line or everything specified in the config file. Removing elevation from the command line or commenting it out in the config file works for sun syncing.

I'm using 2.1.1 from AUR.

Can't set background without root permissions

Me again!

So, I have no trouble using feh to set background, and dyn-wall-rs runs fine, no errors, and reports that it has set the background...but it doesn't actually change. Running with root permissions (sudo) fixes this problem.

 λ ls -al /home/acron/.cargo/bin/ | grep dyn
-rwsrwxr-x 1 acron acron 1321000 Jun 18 10:20 dyn-wall-rs

Is it me?

Readme and program arguments don't match

Love the support for running external commands! I noticed that in the readme the -l parameter is described as -p. Perhaps there are more outdated/changed things in the readme?

Standard config file

Guy from reddit, I noticed the config file is custom, which while in its current state is pretty easy to understand, it would be even more intuitive with a common kind of config file. Here is an example from one of my own projects that I think could be adapted to this one.

use crate::log::{info, warn};
use crate::GenError;
use directories_next::ProjectDirs;
use serde::{Deserialize, Serialize};
use std::fs;
use std::io::prelude::*;

pub fn load() -> Result<Config, GenError> {
    let dirs = ProjectDirs::from("org", "abyss", "rib").ok_or("Dirs error!")?;
    let config = dirs.config_dir().join("config.ron");

    // create folders if they don't exist
    fs::create_dir_all(dirs.config_dir()).unwrap_or(());

    info!("Opening config, and creating if not already there");
    let mut file = fs::OpenOptions::new()
        .read(true)
        .write(true)
        .create(true)
        .open(&config)?;

    let mut ron = String::new();
    file.read_to_string(&mut ron)?;

    info!("Attempting deserialization");
    let config: Config = match ron::de::from_str(&ron) {
        Ok(c) => c,
        Err(_) => {
            warn!("Malformed config file, overwriting");
            let config = Default::default();
            let ron = ron::ser::to_string_pretty(&config, Default::default())?;
            file.write(ron.as_bytes())?;
            config
        }
    };
    info!("Config returned");
    Ok(config)
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
    secret: String,
    key: String,
    totp: String,
}

impl Config {
    pub fn to_tuple(self) -> (String, String, String) {
        (self.key, self.secret, self.totp)
    }
}

impl Default for Config {
    fn default() -> Self {
        Config {
            secret: String::new(),
            key: String::new(),
            totp: String::new(),
        }
    }
}

Background fails to be set if absolute path isn't specified.

Thank you for the awesome program! I plan to start using exclusively!

At least in Ubuntu when I try:

> dyn-wall-rs -a temp2/
temp2/boo.png has been set as your wallpaper

But my background turns completely dark. This is because dyn-wall-rs generates the call:

gsettings set org.gnome.desktop.background picture-uri 'file://temp2/boo.png'

Which will silently succeed as gsettings doesn't report this as an error, but gsettings only works when the absolute path is specified. The "fix" is for me to include the full path from /.

I think dyn-wall-rs should check if the path the user passed is an absolute path and if not, either report an error or you can use std::fs::canonicalize to fetch the absolute path.

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.