Added Night light support with respective icons

This commit is contained in:
tr1x_em committed 2025-08-13 16:18:25 +05:30
1 parent 0868ff3964
commit 3fac357112
7 files changed
+389 -44

No files matched your search

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="-10 -10 45 45"
width="28"
height="28"
stroke="#fff"
stroke-width="2"
fill="#2369ff"
stroke-linecap="round"
stroke-linejoin="round"
class="css-i6dzq1"
version="1.1"
id="svg1"
sodipodi:docname="redshift-status-off.svg"
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showguides="true"
inkscape:zoom="18.857143"
inkscape:cx="14.05303"
inkscape:cy="7.5833333"
inkscape:window-width="1912"
inkscape:window-height="1045"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1">
<sodipodi:guide
position="10.319824,35.042392"
orientation="0,-1"
id="guide1"
inkscape:locked="false" />
<sodipodi:guide
position="28.426625,19.71147"
orientation="1,0"
id="guide2"
inkscape:locked="false" />
<sodipodi:guide
position="20.16424,10.821533"
orientation="0,-1"
id="guide3"
inkscape:locked="false" />
<sodipodi:guide
position="15.405495,21.859464"
orientation="1,0"
id="guide4"
inkscape:locked="false" />
</sodipodi:namedview>
<circle
cx="12"
cy="12"
r="18"
stroke="#2369ff"
stroke-width="1.5"
fill="#2369ff"
id="circle1" />
<polyline
points="6.5 6.5 17.5 17.5 12 23 12 1 17.5 6.5 6.5 17.5"
id="polyline1"
style="display:none" />
<path
class="ColorScheme-Text"
d="M 9.477337,-0.04424821 A 1.2054857,1.2054857 0 0 0 8.7647949,1.0543786 V 8.8200931 L 4.9854372,6.4595221 a 1.2053572,1.2053572 0 0 0 -1.663714,0.38295 1.2053572,1.2053572 0 0 0 0.38295,1.663714 l 4.790089,2.9945889 -4.790089,2.99459 a 1.2053572,1.2053572 0 0 0 -0.38295,1.663714 1.2053572,1.2053572 0 0 0 1.663714,0.38295 l 3.7793577,-2.360572 v 7.765715 a 1.2054857,1.2054857 0 0 0 2.0057141,0.900884 l 7.232143,-6.428572 a 1.2054857,1.2054857 0 0 0 -0.160088,-1.924232 l -4.790089,-2.994589 4.790089,-2.9945899 a 1.2054857,1.2054857 0 0 0 0.160088,-1.924232 L 10.770509,0.15326969 a 1.2054857,1.2054857 0 0 0 -1.293252,-0.1977589 z m 1.698108,3.78241081 4.021071,3.5752505 -4.021071,2.51116 z m 0,9.4387504 4.021071,2.511161 -4.021071,3.57525 z"
fill="currentColor"
id="path1"
style="color:#f2f2f2;display:none;fill:#ffffff;stroke-width:0;stroke-dasharray:none" />
<circle
cx="11.964287"
cy="11.976461"
r="18"
stroke="#aaaaaa"
stroke-width="1.5"
fill="#aaaaaa"
id="circle1-2" />
<path
class="ColorScheme-Text"
d="m 11.812819,1.5209672 c -4.093438,0 -7.40941,3.3298089 -7.40941,7.4376591 0,2.4214697 1.1401375,4.5540907 2.9417973,5.9089617 0.82157,0.61978 1.5116889,1.426592 1.5116889,2.536489 l 0.073193,1.413201 h 5.7654048 l 0.08727,-1.413201 c 0.05765,-1.10984 0.676079,-1.916709 1.497708,-2.536489 1.801688,-1.354871 2.941797,-3.487492 2.941797,-5.9089617 -5e-6,-4.1078502 -3.315972,-7.4376591 -7.409409,-7.4376591 z m 0,1.441351 c 3.311792,0 5.968058,2.6639048 5.968058,5.9963081 0,1.9696057 -0.913528,3.6642007 -2.367563,4.7576097 -1.020376,0.769755 -1.980272,2.000019 -2.069059,3.600495 v 0.0086 l -0.0029,0.0057 -0.0028,0.045 h -3.037426 l -0.0028,-0.04504 v 0.07319 C 10.298324,15.69514 9.2036077,14.463936 8.2122609,13.716165 6.7582261,12.622755 5.844698,10.92816 5.844698,8.9585542 c 0,-3.3324032 2.6562656,-5.996308 5.968058,-5.996308 z M 8.9301158,20.258529 v 1.44135 h 5.7654052 v -1.44135 z m 1.4413512,2.882701 v 1.441351 H 13.25417 V 23.14123 Z"
fill="currentColor"
id="path1-5"
style="color:#f2f2f2;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:0.803571;stroke-dasharray:none;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="-10 -10 45 45"
width="28"
height="28"
stroke="#fff"
stroke-width="2"
fill="#2369ff"
stroke-linecap="round"
stroke-linejoin="round"
class="css-i6dzq1"
version="1.1"
id="svg1"
sodipodi:docname="bluetooth.svg"
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showguides="true"
inkscape:zoom="18.857143"
inkscape:cx="14.05303"
inkscape:cy="7.5833333"
inkscape:window-width="1912"
inkscape:window-height="1045"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1">
<sodipodi:guide
position="10.319824,35.042392"
orientation="0,-1"
id="guide1"
inkscape:locked="false" />
<sodipodi:guide
position="28.426625,19.71147"
orientation="1,0"
id="guide2"
inkscape:locked="false" />
<sodipodi:guide
position="20.16424,10.821533"
orientation="0,-1"
id="guide3"
inkscape:locked="false" />
<sodipodi:guide
position="15.405495,21.859464"
orientation="1,0"
id="guide4"
inkscape:locked="false" />
</sodipodi:namedview>
<circle
cx="12"
cy="12"
r="18"
stroke="#2369ff"
stroke-width="1.5"
fill="#2369ff"
id="circle1" />
<polyline
points="6.5 6.5 17.5 17.5 12 23 12 1 17.5 6.5 6.5 17.5"
id="polyline1"
style="display:none" />
<path
class="ColorScheme-Text"
d="M 9.477337,-0.04424821 A 1.2054857,1.2054857 0 0 0 8.7647949,1.0543786 V 8.8200931 L 4.9854372,6.4595221 a 1.2053572,1.2053572 0 0 0 -1.663714,0.38295 1.2053572,1.2053572 0 0 0 0.38295,1.663714 l 4.790089,2.9945889 -4.790089,2.99459 a 1.2053572,1.2053572 0 0 0 -0.38295,1.663714 1.2053572,1.2053572 0 0 0 1.663714,0.38295 l 3.7793577,-2.360572 v 7.765715 a 1.2054857,1.2054857 0 0 0 2.0057141,0.900884 l 7.232143,-6.428572 a 1.2054857,1.2054857 0 0 0 -0.160088,-1.924232 l -4.790089,-2.994589 4.790089,-2.9945899 a 1.2054857,1.2054857 0 0 0 0.160088,-1.924232 L 10.770509,0.15326969 a 1.2054857,1.2054857 0 0 0 -1.293252,-0.1977589 z m 1.698108,3.78241081 4.021071,3.5752505 -4.021071,2.51116 z m 0,9.4387504 4.021071,2.511161 -4.021071,3.57525 z"
fill="currentColor"
id="path1"
style="color:#f2f2f2;display:none;fill:#ffffff;stroke-width:0;stroke-dasharray:none" />
<path
class="ColorScheme-Text"
d="m 11.812819,1.5209672 c -4.093438,0 -7.40941,3.3298089 -7.40941,7.4376591 0,2.4214697 1.1401375,4.5540907 2.9417973,5.9089617 0.82157,0.61978 1.5116889,1.426592 1.5116889,2.536489 l 0.073193,1.413201 h 5.7654048 l 0.08727,-1.413201 c 0.05765,-1.10984 0.676079,-1.916709 1.497708,-2.536489 1.801688,-1.354871 2.941797,-3.487492 2.941797,-5.9089617 -5e-6,-4.1078502 -3.315972,-7.4376591 -7.409409,-7.4376591 z m 0,1.441351 c 3.311792,0 5.968058,2.6639048 5.968058,5.9963081 0,1.9696057 -0.913528,3.6642007 -2.367563,4.7576097 -1.020376,0.769755 -1.980272,2.000019 -2.069059,3.600495 v 0.0086 l -0.0029,0.0057 -0.0028,0.045 h -3.037426 l -0.0028,-0.04504 v 0.07319 C 10.298324,15.69514 9.2036077,14.463936 8.2122609,13.716165 6.7582261,12.622755 5.844698,10.92816 5.844698,8.9585542 c 0,-3.3324032 2.6562656,-5.996308 5.968058,-5.996308 z M 8.9301158,20.258529 v 1.44135 h 5.7654052 v -1.44135 z m 1.4413512,2.882701 v 1.441351 H 13.25417 V 23.14123 Z"
fill="currentColor"
id="path1-5"
style="color:#f2f2f2;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:0.803571;stroke-dasharray:none;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

+42 -32
View File
@@ -14,6 +14,7 @@ from gi.repository import Gdk, GLib
from loguru import logger
from modules.controlcenter.bluetooth import BluetoothConnections
from modules.controlcenter.expanded_player import EmbeddedExpandedPlayer
from modules.controlcenter.nightlight import create_night_light_widget
from modules.controlcenter.per_app_volume import PerAppVolumeControl
from modules.controlcenter.player import PlayerBoxStack
from modules.controlcenter.wifi import WifiConnections
@@ -298,17 +299,18 @@ class ModusControlCenter(Window):
self.flight_widget = Button(
name="flight-widget",
child=Box(
orientation="h",
spacing=4,
h_align="start",
v_align="center",
orientation="v",
h_expand=True,
v_expand=True,
spacing=8,
h_align="center",
v_align="center",
children=[
self.flight_icon,
Label(
label="Flight",
style_classes="title",
h_align="start",
style_classes="title-widget",
h_align="center",
),
],
),
@@ -334,32 +336,37 @@ class ModusControlCenter(Window):
self.caffeine_widget = Button(
name="caffeine-widget",
child=Box(
orientation="h",
spacing=4,
h_align="start",
orientation="v",
spacing=8,
h_expand=True,
v_expand=True,
h_align="center",
v_align="center",
children=[
self.caffeine_icon,
Box(
orientation="vertical",
v_expand=True,
v_align="center",
h_align="start",
h_expand=True,
children=[
Label(
label="Caffeine",
style_classes="title-widget",
h_align="start",
),
self.caffeine_status_label,
],
Label(
label="Caffeine",
style_classes="title-widget",
h_align="center",
),
# Box(
# orientation="vertical",
# v_expand=True,
# v_align="center",
# h_align="center",
# h_expand=True,
# children=[
# # self.caffeine_status_label,
# ],
# ),
],
),
on_clicked=self.toggle_caffeine,
)
# Create night light widget
self.night_light_widget = create_night_light_widget(self)
# Create main widgets directly without XML
self.widgets = Box(
orientation="vertical",
@@ -381,6 +388,7 @@ class ModusControlCenter(Window):
children=[
self.wlan_widget,
self.bluetooth_widget,
self.night_light_widget,
],
),
# Right side: DND, Flight Mode, and Caffeine
@@ -403,19 +411,21 @@ class ModusControlCenter(Window):
orientation="horizontal",
name="flight-caffeine-row",
children=[
# Box(
# orientation="vertical",
# name="flight-widget-container",
# style_classes="menu",
# h_expand=True,
# children=[
# self.flight_widget,
# ],
# ),
Box(
orientation="vertical",
name="flight-widget-container",
style_classes="menu",
h_expand=True,
v_expand=True,
children=[
self.flight_widget,
],
),
Box(
orientation="vertical",
name="caffeine-widget-container",
h_expand=True,
v_expand=True,
style_classes="menu",
children=[
self.caffeine_widget,
+146
View File
@@ -0,0 +1,146 @@
# Standard library imports
import subprocess
# Fabric imports
from fabric.utils.helpers import get_relative_path
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.label import Label
from fabric.widgets.svg import Svg
# Local imports
from loguru import logger
class NightLightControl:
"""Control night light using hyprsunset"""
def __init__(self):
self.is_active = False
self._check_initial_state()
def _check_initial_state(self):
"""Check if hyprsunset is currently running"""
try:
result = subprocess.run(
["pgrep", "-f", "hyprsunset"], capture_output=True, text=True
)
self.is_active = bool(result.stdout.strip())
except Exception as e:
logger.warning(f"Failed to check hyprsunset status: {e}")
self.is_active = False
def toggle(self):
"""Toggle night light on/off"""
try:
if self.is_active:
# Turn off night light by killing hyprsunset
subprocess.run(["pkill", "hyprsunset"], check=False)
self.is_active = False
logger.debug("Night light turned off")
else:
# Turn on night light with default temperature (3000K)
subprocess.Popen(["hyprsunset", "-t", "4500"], start_new_session=True)
self.is_active = True
logger.debug("Night light turned on")
return True
except Exception as e:
logger.warning(f"Failed to toggle night light: {e}")
return False
def set_temperature(self, temperature: int):
"""Set night light temperature (1000-6500K)"""
try:
# Kill existing process
subprocess.run(["pkill", "hyprsunset"], check=False)
# Start with new temperature
subprocess.Popen(
["hyprsunset", "-t", str(temperature)], start_new_session=True
)
self.is_active = True
logger.debug(f"Night light temperature set to {temperature}K")
return True
except Exception as e:
logger.warning(f"Failed to set night light temperature: {e}")
return False
def create_night_light_widget(control_center):
"""Create night light widget for control center"""
# Initialize night light control
night_light = NightLightControl()
# Create icon
night_light_icon = Svg(
name="nightlight-icon",
svg_file=get_relative_path(
"../../config/assets/icons/applets/redshift-status-on.svg"
if night_light.is_active
else "../../config/assets/icons/applets/redshift-status-off.svg"
),
size=42,
)
# Create status label
night_light_status_label = Label(
label="On" if night_light.is_active else "Off",
name="nightlight-widget-label",
style_classes="status-label",
max_chars_width=15,
ellipsization="end",
h_align="start",
)
def toggle_night_light(*_):
"""Toggle night light and update UI"""
if night_light.toggle():
# Update icon
night_light_icon.set_from_file(
get_relative_path(
"../../config/assets/icons/applets/redshift-status-on.svg"
if night_light.is_active
else "../../config/assets/icons/applets/redshift-status-off.svg"
)
)
# Update status label
night_light_status_label.set_label("On" if night_light.is_active else "Off")
# Create widget box (similar to bluetooth_widget structure)
night_light_widget = Box(
name="nightlight-widget",
orientation="h",
h_expand=True,
children=[
Button(
name="nightlight-icon-button",
child=night_light_icon,
on_clicked=toggle_night_light,
),
Button(
name="nightlight-info-button",
child=Box(
name="nightlight-widget-info",
h_expand=True,
v_expand=True,
v_align="center",
h_align="start",
orientation="vertical",
children=[
Label(
name="nightlight-widget-name",
label="Night Light",
style_classes="ct",
h_align="start",
),
night_light_status_label,
],
),
on_clicked=toggle_night_light,
),
],
)
return night_light_widget
+5 -4
View File
@@ -720,16 +720,17 @@ class PlayerBox(Box):
# ],
)
self.box = Box(
self.box = CenterBox(
name="box-c",
orientation="h",
h_align="center",
h_expand=True,
children=[
start_children=[
self.outer_box,
self.button_box,
# self.stack_buttons_box,
],
end_children=[
self.button_box,
],
)
self.children = [
+15 -7
View File
@@ -50,9 +50,10 @@
}
/* Widgets */
#wifi-widget,
#bluetooth-widget {
#bluetooth-widget,
#nightlight-widget {
min-width: 140px;
padding: 10px 0 0px 0;
padding: 5px 0 0px 0;
}
.icon {
@@ -62,7 +63,8 @@
}
#bluetooth-widget-label,
#wifi-widget-label {
#wifi-widget-label,
#nightlight-widget-label {
font-size: 12px;
margin-left: 5px;
font-weight: 500;
@@ -283,7 +285,8 @@
}
#bluetooth-widget-name,
#wifi-widget-name {
#wifi-widget-name,
#nightlight-widget-name {
margin-top: 6px;
font-size: 14px;
font-weight: bold;
@@ -953,9 +956,9 @@
/* margin-right: 8px; */
}
#flight-icon {
margin-left: -10px;
}
/* #flight-icon { */
/* margin-left: -10px; */
/* } */
.title-widget {
/* margin-top: -14px; */
@@ -978,3 +981,8 @@
#app-control-box {
min-width: 100px;
}
#caffeine-widget,
#flight-widget {
padding: 0px 0 5px 0;
min-width: 50px;
}
+1 -1
View File
@@ -56,7 +56,7 @@
margin-bottom: 0.5rem;
min-height: 50px;
min-width: 220px;
min-width: 330px;
/* border-radius: 8px; */
/* margin: 0 6px 10px; */
/* border: 0.5px solid alpha(#000, 0.4); */