]> Freerunner's - dotfiles.git/commitdiff
hypr: add wl-gammarelay
authorAndre Ramnitz <tux.rising@gmail.com>
Tue, 26 Dec 2023 23:15:19 +0000 (00:15 +0100)
committerAndre Ramnitz <tux.rising@gmail.com>
Sun, 18 Aug 2024 16:18:52 +0000 (18:18 +0200)
config/hypr/scripts/daemons.sh
config/hypr/scripts/gammarelay-autotemp.py [new file with mode: 0755]
config/hypr/scripts/gammarelay-invert.sh [new file with mode: 0755]
config/waybar/config
config/waybar/style.css

index 285929450a08e2bea5e0bcbd7bbe7f7020d67e6e..6da4067a18931e45357f9332dc1023533f230d4c 100755 (executable)
@@ -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 (executable)
index 0000000..c591cfa
--- /dev/null
@@ -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 (executable)
index 0000000..d12c814
--- /dev/null
@@ -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
index 4f8ac47b1f366f65ebd62ea51f1d0bfd09f8524a..876751632f63024258bfd8ca22d05d20a160a9e6 100644 (file)
@@ -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"],
 
 
     "clock": {
-        // "timezone": "America/New_York",
+        "timezone": "Europe/Berlin",
         "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
         "format-alt": "{:%Y-%m-%d}"
     },
 
 
     "idle_inhibitor": {
-        "format": "{icon}",
+        "format": " {icon} ",
         "format-icons": {
             "activated": "",
             "deactivated": ""
        "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
index 8e7d78dee4b45e04a90b34dbb9a8cd8334d49bdf..94aeb804a5b81ead1b90539682605bbdbc63e7ad 100644 (file)
@@ -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;