From: Andre Ramnitz Date: Tue, 26 Dec 2023 23:15:19 +0000 (+0100) Subject: hypr: add wl-gammarelay X-Git-Tag: v0.2~272 X-Git-Url: https://git.ramnitz.eu/?a=commitdiff_plain;h=b51b639f2926ae05721de3c1a9ac6b357b1dbf61;p=dotfiles.git hypr: add wl-gammarelay --- diff --git a/config/hypr/scripts/daemons.sh b/config/hypr/scripts/daemons.sh index 28592945..6da4067a 100755 --- a/config/hypr/scripts/daemons.sh +++ b/config/hypr/scripts/daemons.sh @@ -14,6 +14,13 @@ if [[ ! $(pidof swww-daemon) ]]; then swww img ~/Bilder/Wallpapers/default.jpg & fi +if [[ ! $(pidof wl-gammarelay-rs) ]]; then + "$HOME"/.cargo/bin/wl-gammarelay-rs > /dev/null 2>&1 & + logger 'gammarelay started' + "$HOME"/.config/hypr/scripts/gammarelay-autotemp.py & + logger 'gammarelay-autotemp started' +fi + openrgb -p simple.orp & kcr create -c main -s default & # kakoune default server diff --git a/config/hypr/scripts/gammarelay-autotemp.py b/config/hypr/scripts/gammarelay-autotemp.py new file mode 100755 index 00000000..c591cfa6 --- /dev/null +++ b/config/hypr/scripts/gammarelay-autotemp.py @@ -0,0 +1,34 @@ +#!/bin/python + +import datetime as dt +import time +import subprocess + +## Tested parameter space: +# dusk_time < 3600 + dawn_time +# 3600 < dusk_time + +temp_day = 6500 +temp_night = 3800 +dawn_time = 9 * 3600 # 9am +dusk_time = 19 * 3600 # 19pm + +while True: + temp = temp_day + now = dt.datetime.now() + curr_time = int( + (now - now.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds() + ) + if dawn_time - 3600 < curr_time < dawn_time: + temp = (dawn_time - curr_time) * (temp_night - temp_day) / 3600 + temp_day + if dusk_time - 3600 < curr_time < dusk_time: + temp = (dusk_time - curr_time) * (temp_day - temp_night) / 3600 + temp_night + print("check") + if dusk_time < curr_time or curr_time < dawn_time: + temp = temp_night + temp = int(temp) + subprocess.run( + f"busctl --user set-property rs.wl-gammarelay / rs.wl.gammarelay Temperature q {temp}", + shell=True, + ) + time.sleep(1) diff --git a/config/hypr/scripts/gammarelay-invert.sh b/config/hypr/scripts/gammarelay-invert.sh new file mode 100755 index 00000000..d12c8149 --- /dev/null +++ b/config/hypr/scripts/gammarelay-invert.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# The human eye is more sensitive to contrast at high than at low +# levels of intensity. Thus, contast at high levels of intensity is +# lost if the display is inverted. This script compensates for this by +# gamma correction. The value of γ=0.6 is not based on any theory; +# adjust it to your liking. + +dbus="rs.wl-gammarelay / rs.wl.gammarelay" + +if [ "$(busctl --user get-property $dbus Inverted)" = "b false" ]; then + busctl --user set-property $dbus Inverted b true + busctl --user set-property $dbus Gamma d 0.6 +else + busctl --user set-property $dbus Inverted b false + busctl --user set-property $dbus Gamma d 1.0 +fi diff --git a/config/waybar/config b/config/waybar/config index 4f8ac47b..87675163 100644 --- a/config/waybar/config +++ b/config/waybar/config @@ -1,3 +1,4 @@ +//# kak: filetype=json:ts=4:iw=4 { "layer": "top", // Waybar at top layer "position": "bottom", // Waybar position (top|bottom|left|right) @@ -5,7 +6,7 @@ // "width": 1280, // Waybar width "spacing": -8, // Gaps between modules (4px) // Choose the order of the modules - "modules-left": ["hyprland/workspaces", "mpd"], + "modules-left": ["hyprland/workspaces", "custom/spacer", "custom/gammarelay-temperature", "custom/gammarelay-gamma", "custom/gammarelay-brightness", "mpd"], "modules-center": ["hyprland/window"], "margin": "0", "modules-right": ["keyboard-state", "cpu", "memory", "temperature#temp2", "temperature", "pulseaudio", "clock", "tray", "idle_inhibitor", "custom/wallpaper", "custom/powermenu"], @@ -174,14 +175,14 @@ "clock": { - // "timezone": "America/New_York", + "timezone": "Europe/Berlin", "tooltip-format": "{:%Y %B}\n{calendar}", "format-alt": "{:%Y-%m-%d}" }, "idle_inhibitor": { - "format": "{icon}", + "format": " {icon} ", "format-icons": { "activated": "", "deactivated": "" @@ -203,5 +204,32 @@ "tooltip": false, "interval": "once", }, + + "custom/spacer": { + "format": " ", + "tooltip": false, + }, + + "custom/gammarelay-temperature": { + "format": " {}", + "exec": "wl-gammarelay-rs watch {t}", + "on-scroll-up": "busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay UpdateTemperature n +100", + "on-scroll-down": "busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay UpdateTemperature n -100", + "interval": "2" + }, + "custom/gammarelay-brightness": { + "format": " {}%", + "exec": "wl-gammarelay-rs watch {bp}", + "on-scroll-up": "busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay UpdateBrightness d +0.02", + "on-scroll-down": "busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay UpdateBrightness d -0.02", + "interval": "2" + }, + "custom/gammarelay-gamma": { + "format": "𝛄 {}%", + "exec": "wl-gammarelay-rs watch {g}", + "on-scroll-up": "busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay UpdateGamma d +0.02", + "on-scroll-down": "busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay UpdateGamma d -0.02", + "interval": "2" + }, + } -# kak: filetype=json:ts=2:iw=2 diff --git a/config/waybar/style.css b/config/waybar/style.css index 8e7d78de..94aeb804 100644 --- a/config/waybar/style.css +++ b/config/waybar/style.css @@ -34,12 +34,13 @@ window#waybar.foot { /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ button:hover { + padding: 0 8px; background: inherit; box-shadow: inset 0 -3px #ffffff; } #workspaces { - padding: 0 10px; + padding: 0 8px; background-image: linear-gradient(0deg, rgba(228,169,68, 0.9), rgba(228,169,68, 0.6), rgba(59, 64, 69, 0.5)); border-bottom: 3px solid rgba(100, 114, 125, 1); color: #181818; @@ -93,7 +94,7 @@ button:hover { #mpd { - padding: 0 24px; + padding: 0 16px; margin: 0 4px; color: #eff0f1; font-family: "IBM Plex Serif"; @@ -104,28 +105,38 @@ button:hover { #clock { padding-left: 16px; - padding-right: 32px; margin: 0 4px; } -#idle_inhibitor { +#custom-spacer { + padding: 0 0px; + margin: 0 1px; +} + + +#idle_inhibitor, +#custom-powermenu, +#custom-wallpaper { padding: 0 8px; margin: 0 4px; color: #181818; background-image: linear-gradient(0deg, rgba(228,169,68, 0.9), rgba(228,169,68, 0.6), rgba(59, 64, 69, 0.5)); border-bottom: 3px solid rgba(100, 114, 125, 1); } -#custom-powermenu, -#custom-wallpaper { - padding: 0 8px; - padding-right: 0px; + + +#custom-gammarelay-temperature, +#custom-gammarelay-gamma, +#custom-gammarelay-brightness { + padding: 0 16px; margin: 0 4px; color: #181818; - background-image: linear-gradient(0deg, rgba(228,169,68, 0.9), rgba(228,169,68, 0.6), rgba(59, 64, 69, 0.5)); + background-image: linear-gradient(0deg, rgba(124,184,143, 0.9), rgba(124,184,143, 0.6), rgba(59, 64, 69, 0.5)); border-bottom: 3px solid rgba(100, 114, 125, 1); } + #tray { padding: 0 16px; margin: 0 4px;