Giter Site home page Giter Site logo

braun-steven / audamo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.03 MB

Automatically set linux themes based on time or local sunrise and sunset.

Home Page: https://www.steven-braun.com/audamo/

License: MIT License

Python 83.41% Shell 16.59%
auto cursor dark dark-mode gdk gtk hyprland i3 icon light

audamo's Introduction

Python Version License AUR

Audamo

Audamo is a project designed to smoothly provide what fully featured desktop environments such as Gnome and KDE provide: An automated transition of themes between light and dark mode depending on time or location. This is particularly helpful for non-desktop environments such as i3wm, sway, hyprland, awesomewm, bspwm, dwm, and many more. Audamo can be configured to switch themes based on sunrise/sunset times at a given or inferred location or simply by a specified schedule. Additionally, Audamo allows for the execution of custom scripts during theme changes, enabling users to hook additional scripts into the theme toggle process.

Until now, Audamo can set the following theme elements (config.toml values in brackets; see also Configuration):

  • GTK theme (theme)
  • Icon theme (icon)
  • Cursor theme (cursor)
  • GTK color-scheme preference

A user-specified script (custom-script-path) can be run with every theme change, allowing for additional customization; see also Custom Script.


Installation

Install Script

Install conveniently with the install script.

bash <(curl -s -L https://raw.githubusercontent.com/braun-steven/audamo/main/install.sh)

Dependencies

Audamo requires the following Python packages to be installed (see requirements.txt for more specific versions):

  • astral
  • requests
  • tomli

Arch Linux (AUR)

Audamo is available in the AUR as audamo:

paru -S audamo

You can now copy the default system-wide configuration into your user config:

cp /usr/share/audamo/config.toml $XDG_CONFIG_HOME/audamo/config.toml

Usage

Audamo is intended to be run as a background process that checks for location or time and, based on this, applies dark or light settings defined in config.toml.

Systemd

We provide systemd user units to run audamo --daemon as a serviced service as well:

systemctl --user enable --now audamo.service

Daemon Mode

If systemd is not available or not desired, audamo can also be run in daemon mode:

audamo --daemon

Manual

Instead of using Audamo as a service/daemon, you can run it manually with a single invocation. Based on the config.toml settings, this will update the theme to light/dark mode:

$ audamo --help
usage: audamo [-h] [-l] [-d] [--debug] [--list-themes] [--daemon] [-v] [-c CONFIG] [--print-config]

Automatically set the system theme based on time or local sunrise and sunset.

options:
  -h, --help            show this help message and exit
  -l, --light           Force theme to light mode. (default: False)
  -d, --dark            Force theme to dark mode. (default: False)
  --debug               Enable debug logging to console. (default: False)
  --list-themes         List available themes, cursors, and icons. (default: False)
  --daemon              Run as a daemon to continuously monitor the time. (default: False)
  -v, --version         show program's version number and exit
  -c CONFIG, --config CONFIG
                        Specify the configuration file to use (default: None)
  --print-config        Print the configuration file and exit. (default: False)

Configuration

Audamo can be configured by editing the config.toml file. The user configuration should be placed at $XDG_CONFIG_HOME/audamo/config.toml.

# Specify location by latitude and longitude
[general]
latitude = ""
longitude = ""

# Time in the format "%H:%M"
sunrise = "08:00"
sunset = "20:00"

# Theme mode:
#  - "location": sets the theme based on sunrise/sunset at given location
#  - "time": sets the theme
mode = "location"

# Custom script that also gets executed with a single argument which is either "light" or "dark"
# This script may contain user specified `sed` instructions to e.g. replace the vim theme like "sed -i s/colorscheme dark/colorscheme light/g ~/.vimrc" or similar
# Make sure that the script has a proper shebang, e.g. "#!/bin/sh" for shell scripts
custom-script-path = ""

# Light theme elements
# Set values to "" if they should not be changed
[light]
theme = "Adwaita"
icon = "Adwaita"
cursor = "Adwaita"

# Dark theme elements
# Set values to "" if they should not be changed
[dark]
theme = "Adwaita-dark"
icon = "Adwaita"
cursor = "Adwaita"

Custom Script

A custom script can get executed every time audamo is run. The script path can be configured in config.toml with the custom-script-path variable. The script is run with a single argument which is either "light" or "dark". This script may contain user-specified sed instructions to replace the vim theme like sed e.g. -i s/colorscheme dark/colorscheme light/g ~/.vimrc or similar. Make sure that the script has a proper shebang, e.g. #!/bin/sh for shell scripts.

An example script can be found in example-custom-script.sh:

#!/usr/bin/env sh
# This script takes a single argument, either "light" or "dark".

THEME="$1"
case $THEME in
    light)
        # Sway background
        swaymsg "output * bg ~/lakesidedeer-light.png fill"

        # Alacritty
        sed -i 's/nord/github_light/g' ~/.config/alacritty/alacritty.toml

        # Vim
        sed -i 's/background=dark/background=light/g' ~/.vimrc
        ;;
    dark)
        # Sway background
        swaymsg "output * bg ~/lakesidedeer-dark.png fill"

        # Alacritty
        sed -i 's/github_light/nord/g' ~/.config/alacritty/alacritty.toml

        # Vim
        sed -i 's/background=light/background=dark/g' ~/.vimrc
        ;;
    *)
        echo "Invalid argument. Please use 'light' or 'dark'."
        exit 1
        ;;
esac

Uninstall

If Audamo was installed via the install script, it can likewise be uninstalled with the uninstall script:

bash <(curl -s -L https://raw.githubusercontent.com/braun-steven/audamo/main/uninstall.sh)

Changelog

Version 1.1.4

  • Add fallbacks to location fetching and config parsing logic

Version 1.1.3

  • Fix a timezone bug for sunrise/sunset

Version 1.1.2

  • Hotfix slip of syntax error

Version 1.1.1

  • Remove sleep until the next sunrise/sunset as this was not compatible with suspending systems

Version 1.1.0

  • Add print config flag
  • Implement sleep until the next sunrise/sunset
  • Fix theme detection when the theme does not have an index.theme file
  • Rewrite core logic
  • Get rid of timezonefinder dependency
  • Remove systemd timer and make the service start the daemon

audamo's People

Contributors

braun-steven avatar

Watchers

 avatar

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.