Skip to content

Commit

Permalink
patch(system/power): unmount-samba before-sleep (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
piyoki authored Feb 21, 2024
1 parent 83f6637 commit 1569d2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
9 changes: 5 additions & 4 deletions home/services/systemd/powermanagement/swayidle.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{ inputs, pkgs, system, ... }:
{ inputs, pkgs, config, system, ... }:

# $HOME/.config/systemd/user/swayidle.service
let
swayidleBin = inputs.nixpkgs-wayland.packages.${system}.swayidle;
swaylockBin = inputs.nixpkgs-wayland.packages.${system}.swaylock-effects;
swBin = "/run/current-system/sw/bin";
in
{
Expand All @@ -15,10 +16,10 @@ in
ExecStart = "${pkgs.writeShellScript "lockscreen" ''
set -eux
${swayidleBin}/bin/swayidle -w \
timeout 300 'swaylock -f' \
timeout 300 '${swaylockBin}/bin/swaylock -f' \
timeout 360 'hyprctl dispatch dpms off' \
resume 'hyprctl dispatch dpms on' \
before-sleep 'swaylock -f'
before-sleep 'unmount-samba && ${swaylockBin}/bin/swaylock -f'
''}";
ExecStartPost = "${swBin}/sleep 1";
ExecStop = "${pkgs.writeShellScript "lockscreen" ''
Expand All @@ -29,7 +30,7 @@ in
RemainAfterExit = "yes";
Type = "oneshot";
Environment = [
"PATH=$PATH:/run/current-system/sw/bin"
"PATH=$PATH:/run/current-system/sw/bin:${config.home.homeDirectory}/.local/scripts"
];
};
};
Expand Down
24 changes: 13 additions & 11 deletions system/services/powermanagement.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,23 @@ in
};

# systemd unit
# set battery charge max and min threshold
systemd.services."battery_charge_threshold" = {
wantedBy = [ "multi-user.target" ];
after = [ "multi-user.target" ];
description = "Set the battery charge threshold";
serviceConfig = {
ExecStart = "${pkgs.writeShellScript "lockscreen" ''
systemd.services = {
# set battery charge max and min threshold
"battery_charge_threshold" = {
wantedBy = [ "multi-user.target" ];
after = [ "multi-user.target" ];
description = "Set the battery charge threshold";
serviceConfig = {
ExecStart = "${pkgs.writeShellScript "lockscreen" ''
set -eux
${swBin}/echo 0 > /sys/class/power_supply/BAT0/charge_control_start_threshold
${swBin}/echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold
''}";
Type = "oneshot";
Environment = [
"PATH=$PATH:${swBin}"
];
Type = "oneshot";
Environment = [
"PATH=$PATH:${swBin}"
];
};
};
};

Expand Down

0 comments on commit 1569d2d

Please sign in to comment.