feat(hyprlock): show idle inhibit feedback
This commit was merged in pull request #57.
This commit is contained in:
@@ -12,15 +12,24 @@ let
|
|||||||
# The hyprlock this module installs, used by the lock keybind below.
|
# The hyprlock this module installs, used by the lock keybind below.
|
||||||
hyprlock = "${config.home-manager.users.${user}.programs.hyprlock.package}/bin/hyprlock";
|
hyprlock = "${config.home-manager.users.${user}.programs.hyprlock.package}/bin/hyprlock";
|
||||||
|
|
||||||
|
sleepIcon = builtins.fromJSON ''"\udb81\udcb2"'';
|
||||||
|
sleepOffIcon = builtins.fromJSON ''"\udb81\udcb3"'';
|
||||||
|
|
||||||
idleLockToggle = pkgs.writeShellScript "lockscreen-idle-inhibit-toggle" ''
|
idleLockToggle = pkgs.writeShellScript "lockscreen-idle-inhibit-toggle" ''
|
||||||
unit=lockscreen-idle-inhibit.service
|
unit=lockscreen-idle-inhibit.service
|
||||||
|
|
||||||
|
refresh_waybar() {
|
||||||
|
${pkgs.procps}/bin/pkill -RTMIN+9 waybar >/dev/null 2>&1 || true
|
||||||
|
}
|
||||||
|
|
||||||
if ${pkgs.systemd}/bin/systemctl --user is-active --quiet "$unit"; then
|
if ${pkgs.systemd}/bin/systemctl --user is-active --quiet "$unit"; then
|
||||||
${pkgs.systemd}/bin/systemctl --user stop "$unit"
|
${pkgs.systemd}/bin/systemctl --user stop "$unit"
|
||||||
|
refresh_waybar
|
||||||
|
${pkgs.swayosd}/bin/swayosd-client --custom-message "${sleepIcon}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${pkgs.systemd}/bin/systemd-run \
|
if ${pkgs.systemd}/bin/systemd-run \
|
||||||
--user \
|
--user \
|
||||||
--collect \
|
--collect \
|
||||||
--unit=lockscreen-idle-inhibit \
|
--unit=lockscreen-idle-inhibit \
|
||||||
@@ -29,7 +38,10 @@ let
|
|||||||
--what=idle \
|
--what=idle \
|
||||||
--who=lockscreen-hotkey \
|
--who=lockscreen-hotkey \
|
||||||
--why="lock screen disabled by hotkey" \
|
--why="lock screen disabled by hotkey" \
|
||||||
${pkgs.coreutils}/bin/sleep infinity
|
${pkgs.coreutils}/bin/sleep infinity >/dev/null; then
|
||||||
|
refresh_waybar
|
||||||
|
${pkgs.swayosd}/bin/swayosd-client --custom-message "${sleepOffIcon}"
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ let
|
|||||||
# A Nerd Font Private-Use-Area codepoint as a literal character, decoded
|
# A Nerd Font Private-Use-Area codepoint as a literal character, decoded
|
||||||
# through JSON so the glyph survives as bytes rather than an editor paste.
|
# through JSON so the glyph survives as bytes rather than an editor paste.
|
||||||
g = code: builtins.fromJSON ''"\u${code}"'';
|
g = code: builtins.fromJSON ''"\u${code}"'';
|
||||||
|
sleepOffIcon = builtins.fromJSON ''"\udb81\udcb3"'';
|
||||||
|
|
||||||
# Renders and toggles mako's do-not-disturb mode.
|
# Renders and toggles mako's do-not-disturb mode.
|
||||||
# With no mako daemon answering, the status reads "notifications on", keeping
|
# With no mako daemon answering, the status reads "notifications on", keeping
|
||||||
@@ -38,6 +39,14 @@ let
|
|||||||
printf '{"text":"","class":"idle"}\n'
|
printf '{"text":"","class":"idle"}\n'
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
idleLockStatus = pkgs.writeShellScript "waybar-idle-lock-status" ''
|
||||||
|
if ${pkgs.systemd}/bin/systemctl --user is-active --quiet lockscreen-idle-inhibit.service; then
|
||||||
|
printf '{"text":"${sleepOffIcon}","tooltip":"Idle locking inhibited","class":"inhibited"}\n'
|
||||||
|
else
|
||||||
|
printf '{"text":"","class":"idle"}\n'
|
||||||
|
fi
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.desktop.waybar.enable = lib.mkEnableOption "the Waybar status bar";
|
options.modules.desktop.waybar.enable = lib.mkEnableOption "the Waybar status bar";
|
||||||
@@ -63,6 +72,7 @@ in
|
|||||||
modules-center = [ "clock" ];
|
modules-center = [ "clock" ];
|
||||||
modules-right = [
|
modules-right = [
|
||||||
"custom/recording"
|
"custom/recording"
|
||||||
|
"custom/idle-lock"
|
||||||
"mpris"
|
"mpris"
|
||||||
"wireplumber"
|
"wireplumber"
|
||||||
"network"
|
"network"
|
||||||
@@ -155,6 +165,13 @@ in
|
|||||||
exec = "${recStatus}";
|
exec = "${recStatus}";
|
||||||
interval = 1;
|
interval = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
"custom/idle-lock" = {
|
||||||
|
return-type = "json";
|
||||||
|
exec = "${idleLockStatus}";
|
||||||
|
interval = "once";
|
||||||
|
signal = 9;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user