change import script

Signed-off-by: Hadi <hadi@example.fr>
This commit is contained in:
Hadi
2026-08-17 14:14:01 +02:00
parent 2affa2a8ec
commit 6a2adfb338
6 changed files with 31 additions and 29 deletions
+1 -1
View File
@@ -2,10 +2,10 @@
pkgs, pkgs,
lib, lib,
config, config,
scripts,
... ...
}: let }: let
colors = config.lib.stylix.colors; colors = config.lib.stylix.colors;
scripts = import ../waybar/scripts.nix {inherit pkgs config;};
border-size = config.theme.border-size; border-size = config.theme.border-size;
mkMenu = menu: let mkMenu = menu: let
+1 -1
View File
@@ -1,9 +1,9 @@
{ {
config, config,
pkgs, pkgs,
scripts,
... ...
}: let }: let
scripts = import ../waybar/scripts.nix {inherit pkgs config;};
c = config.lib.stylix.colors; c = config.lib.stylix.colors;
font = config.stylix.fonts.sansSerif.name; font = config.stylix.fonts.sansSerif.name;
monofont = config.stylix.fonts.monospace.name; monofont = config.stylix.fonts.monospace.name;
+2 -4
View File
@@ -1,10 +1,8 @@
{ {
pkgs, pkgs,
config, scripts,
... ...
}: let }: {
scripts = import ../waybar/scripts.nix {inherit pkgs config;};
in {
xdg.desktopEntries = { xdg.desktopEntries = {
focus-toggle = { focus-toggle = {
name = "Focus Mode"; name = "Focus Mode";
+2
View File
@@ -10,6 +10,8 @@ in {
./style.nix ./style.nix
]; ];
_module.args.scripts = scripts;
_module.args.osdPath = scripts.osdPath;
_module.args.networkScript = scripts.networkScript; _module.args.networkScript = scripts.networkScript;
_module.args.bluetoothScript = scripts.bluetoothScript; _module.args.bluetoothScript = scripts.bluetoothScript;
_module.args.volMuteScript = scripts.vol-mute; _module.args.volMuteScript = scripts.vol-mute;
+23 -22
View File
@@ -6,7 +6,7 @@
name = "waybar-osd"; name = "waybar-osd";
runtimeInputs = with pkgs; [procps coreutils]; runtimeInputs = with pkgs; [procps coreutils];
text = '' text = ''
printf '%s' "$1" > /tmp/waybar-osd printf '%s' "$1" > "$XDG_RUNTIME_DIR/waybar-osd"
pkill -f -RTMIN+8 '^waybar$' 2>/dev/null || true pkill -f -RTMIN+8 '^waybar$' 2>/dev/null || true
''; '';
}; };
@@ -15,7 +15,7 @@
name = "waybar-osd-status"; name = "waybar-osd-status";
runtimeInputs = with pkgs; [coreutils]; runtimeInputs = with pkgs; [coreutils];
text = '' text = ''
file=/tmp/waybar-osd file="$XDG_RUNTIME_DIR/waybar-osd"
[ -f "$file" ] || exit 1 [ -f "$file" ] || exit 1
mtime=$(stat -c %Y "$file" 2>/dev/null) || exit 1 mtime=$(stat -c %Y "$file" 2>/dev/null) || exit 1
age=$(( $(date +%s) - mtime )) age=$(( $(date +%s) - mtime ))
@@ -86,8 +86,9 @@
jq -r 'to_entries[] | select(.key != "METADATA") | "\(.value.char) \(.key)"' \ jq -r 'to_entries[] | select(.key != "METADATA") | "\(.value.char) \(.key)"' \
${nerdFontGlyphnames} > "$out" ${nerdFontGlyphnames} > "$out"
''; '';
osdPath = "$XDG_RUNTIME_DIR/waybar-osd";
in { in {
inherit waybar-osd waybar-osd-status battery-monitor; inherit waybar-osd waybar-osd-status battery-monitor osdPath;
bluetoothScript = pkgs.writeShellScript "waybar-bluetooth" '' bluetoothScript = pkgs.writeShellScript "waybar-bluetooth" ''
jq=${pkgs.jq}/bin/jq jq=${pkgs.jq}/bin/jq
@@ -234,19 +235,19 @@ in {
''; '';
wifi-toggle = pkgs.writeShellScriptBin "wifi-toggle" '' wifi-toggle = pkgs.writeShellScriptBin "wifi-toggle" ''
if nmcli radio wifi | grep -q enabled; then if ${pkgs.networkmanager}/bin/nmcli radio wifi | grep -q enabled; then
nmcli radio wifi off ${pkgs.networkmanager}/bin/nmcli radio wifi off
else else
nmcli radio wifi on ${pkgs.networkmanager}/bin/nmcli radio wifi on
fi fi
${updateOsd} ${updateOsd}
''; '';
bluetooth-toggle = pkgs.writeShellScriptBin "bluetooth-toggle" '' bluetooth-toggle = pkgs.writeShellScriptBin "bluetooth-toggle" ''
if bluetoothctl show | grep -q "Powered: yes"; then if ${pkgs.bluez}/bin/bluetoothctl show | grep -q "Powered: yes"; then
bluetoothctl power off ${pkgs.bluez}/bin/bluetoothctl power off
else else
bluetoothctl power on ${pkgs.bluez}/bin/bluetoothctl power on
fi fi
${updateOsd} ${updateOsd}
''; '';
@@ -260,7 +261,7 @@ in {
''; '';
nightshift-toggle = pkgs.writeShellScriptBin "nightshift-toggle" '' nightshift-toggle = pkgs.writeShellScriptBin "nightshift-toggle" ''
if pidof "hyprsunset" > /dev/null; then if ${pkgs.procps}/bin/pidof "hyprsunset" > /dev/null; then
pkill hyprsunset pkill hyprsunset
OSD_TEXT="󰖔 Night Shift Off" OSD_TEXT="󰖔 Night Shift Off"
else else
@@ -271,23 +272,23 @@ in {
''; '';
focus-toggle = pkgs.writeShellScriptBin "focus-toggle" '' focus-toggle = pkgs.writeShellScriptBin "focus-toggle" ''
if test -f /tmp/hypr-focus-mode; then if test -f "$XDG_RUNTIME_DIR/hypr-focus-mode"; then
rm /tmp/hypr-focus-mode rm "$XDG_RUNTIME_DIR/hypr-focus-mode"
OSD_TEXT="󰈈 Focus Off" OSD_TEXT="󰈈 Focus Off"
${updateOsd} ${updateOsd}
hyprctl reload ${pkgs.hyprland}/bin/hyprctl reload
hyprctl dispatch exec waybar ${pkgs.hyprland}/bin/hyprctl dispatch exec waybar
else else
touch /tmp/hypr-focus-mode touch "$XDG_RUNTIME_DIR/hypr-focus-mode"
OSD_TEXT="󰈈 Focus On" OSD_TEXT="󰈈 Focus On"
${updateOsd} ${updateOsd}
pkill waybar || true ${pkgs.procps}/bin/pkill waybar || true
hyprctl keyword animations:enabled false ${pkgs.hyprland}/bin/hyprctl keyword animations:enabled false
hyprctl keyword general:gaps_in 0 ${pkgs.hyprland}/bin/hyprctl keyword general:gaps_in 0
hyprctl keyword general:gaps_out 0 ${pkgs.hyprland}/bin/hyprctl keyword general:gaps_out 0
hyprctl keyword decoration:active_opacity 1 ${pkgs.hyprland}/bin/hyprctl keyword decoration:active_opacity 1
hyprctl keyword decoration:inactive_opacity 1 ${pkgs.hyprland}/bin/hyprctl keyword decoration:inactive_opacity 1
hyprctl keyword decoration:rounding 0 ${pkgs.hyprland}/bin/hyprctl keyword decoration:rounding 0
fi fi
''; '';
+2 -1
View File
@@ -1,6 +1,7 @@
{ {
config, config,
pkgs, pkgs,
osdPath,
networkScript, networkScript,
bluetoothScript, bluetoothScript,
caffeineToggleScript, caffeineToggleScript,
@@ -76,7 +77,7 @@ in {
}; };
"custom/osd" = { "custom/osd" = {
exec = "cat /tmp/waybar-osd"; exec = "cat ${osdPath}";
exec-if = "${osdStatusScript}/bin/waybar-osd-status"; exec-if = "${osdStatusScript}/bin/waybar-osd-status";
signal = 8; signal = 8;
interval = 1; interval = 1;