diff options
-rw-r--r-- | hosts/olive/configuration.nix | 6 | ||||
-rw-r--r-- | mail.nix | 1 | ||||
-rw-r--r-- | programs/neovim.nix | 2 | ||||
-rw-r--r-- | scripts/default.nix | 26 | ||||
-rw-r--r-- | services/battery.nix | 48 | ||||
-rw-r--r-- | services/suspend.nix | 8 |
6 files changed, 30 insertions, 61 deletions
diff --git a/hosts/olive/configuration.nix b/hosts/olive/configuration.nix index 0019695..3c15f74 100644 --- a/hosts/olive/configuration.nix +++ b/hosts/olive/configuration.nix | |||
@@ -8,7 +8,6 @@ | |||
8 | imports = | 8 | imports = |
9 | [ | 9 | [ |
10 | ./hardware-configuration.nix | 10 | ./hardware-configuration.nix |
11 | ../../services/battery.nix | ||
12 | ../../services/suspend.nix | 11 | ../../services/suspend.nix |
13 | ]; | 12 | ]; |
14 | 13 | ||
@@ -92,7 +91,6 @@ | |||
92 | adb.enable = true; | 91 | adb.enable = true; |
93 | }; | 92 | }; |
94 | 93 | ||
95 | |||
96 | sound.enable = true; | 94 | sound.enable = true; |
97 | hardware.pulseaudio = { | 95 | hardware.pulseaudio = { |
98 | enable = true; | 96 | enable = true; |
@@ -114,8 +112,8 @@ | |||
114 | 112 | ||
115 | services.batteryNotifier = { | 113 | services.batteryNotifier = { |
116 | enable = true; | 114 | enable = true; |
117 | notifyCapacity = 40; | 115 | notifyCapacity = 20; |
118 | suspendCapacity = 5; | 116 | suspendCapacity = 10; |
119 | }; | 117 | }; |
120 | 118 | ||
121 | users.users.np = { | 119 | users.users.np = { |
@@ -44,6 +44,5 @@ | |||
44 | userName = "[email protected]"; | 44 | userName = "[email protected]"; |
45 | notmuch.enable = true; | 45 | notmuch.enable = true; |
46 | msmtp.enable = true; | 46 | msmtp.enable = true; |
47 | |||
48 | }; | 47 | }; |
49 | } | 48 | } |
diff --git a/programs/neovim.nix b/programs/neovim.nix index 18baeac..e163d48 100644 --- a/programs/neovim.nix +++ b/programs/neovim.nix | |||
@@ -35,7 +35,7 @@ | |||
35 | vimtex | 35 | vimtex |
36 | 36 | ||
37 | # handy | 37 | # handy |
38 | # vim-gitgutter | 38 | vim-gitgutter |
39 | tabular | 39 | tabular |
40 | emmet-vim | 40 | emmet-vim |
41 | vimwiki | 41 | vimwiki |
diff --git a/scripts/default.nix b/scripts/default.nix index 84fcff3..a6e5936 100644 --- a/scripts/default.nix +++ b/scripts/default.nix | |||
@@ -1,17 +1,31 @@ | |||
1 | { pkgs, ... }: | 1 | { pkgs, ... }: |
2 | 2 | ||
3 | let | 3 | let |
4 | 4 | ||
5 | # open a window with live video feed from the camera | 5 | # open a window with live video feed from the camera |
6 | webcam = pkgs.writeScriptBin "webcam" '' | 6 | webcam = pkgs.writeScriptBin "webcam" '' |
7 | ${pkgs.mpv}/bin/mpv av://v4l2:/dev/video0 --profile=low-latency --untimed | 7 | ${pkgs.mpv}/bin/mpv av://v4l2:/dev/video0 --profile=low-latency --untimed |
8 | ''; | 8 | ''; |
9 | 9 | ||
10 | # create new repo on fern | ||
11 | git-new-repo = pkgs.writeScriptBin "git-new-repo" '' | ||
12 | if [ $# -eq 0 ]; then | ||
13 | echo "requires an arg" | ||
14 | exit 1 | ||
15 | fi | ||
16 | |||
17 | # $1 - section/repo-name | ||
18 | |||
19 | ssh git@ferrn git init --bare "$1"; | ||
20 | git remote add origin git@ferrn:"$1"; | ||
21 | git push -u origin HEAD; | ||
22 | ''; | ||
23 | |||
10 | # set git repo descriptions on cgit | 24 | # set git repo descriptions on cgit |
11 | git-set-desc = pkgs.writeScriptBin "git-set-desc" '' | 25 | git-set-desc = pkgs.writeScriptBin "git-set-desc" '' |
12 | remote=$(git remote get-url --push origin) | 26 | remote=$(git remote get-url --push origin) |
13 | scp .git/description "$remote/description" | 27 | scp .git/description "$remote/description" |
14 | ''; | 28 | ''; |
15 | 29 | ||
16 | # screen record with ffmpeg and slop | 30 | # screen record with ffmpeg and slop |
17 | record = import ./record.nix pkgs; | 31 | record = import ./record.nix pkgs; |
@@ -23,4 +37,10 @@ let | |||
23 | battery = import ./battery.nix pkgs; | 37 | battery = import ./battery.nix pkgs; |
24 | 38 | ||
25 | in | 39 | in |
26 | [ webcam git-set-desc record uploader battery ] | 40 | [ |
41 | webcam | ||
42 | git-set-desc | ||
43 | record | ||
44 | uploader | ||
45 | battery | ||
46 | ] | ||
diff --git a/services/battery.nix b/services/battery.nix deleted file mode 100644 index a871e8f..0000000 --- a/services/battery.nix +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | { config, lib, pkgs, ... }: | ||
2 | |||
3 | with lib; | ||
4 | let | ||
5 | cfg = config.services.battery-alert; | ||
6 | bat = pkgs.writeScriptBin "bat" | ||
7 | '' | ||
8 | ''; | ||
9 | in | ||
10 | { | ||
11 | options.services.battery-alert = { | ||
12 | enable = mkOption { | ||
13 | type = types.bool; | ||
14 | default = false; | ||
15 | description = '' | ||
16 | If enabled, NixOS will periodically check battery levels and report | ||
17 | if it is below a threshold value. | ||
18 | ''; | ||
19 | }; | ||
20 | }; | ||
21 | |||
22 | config = { | ||
23 | systemd.user.timers.battery-alert = mkIf cfg.enable { | ||
24 | description = "Periodically check battery status and alert if required"; | ||
25 | timerConfig.OnBootSec = "1m"; | ||
26 | timerConfig.OnUnitInactiveSec = "1m"; | ||
27 | timerConfig.Unit = "battery-alert.service"; | ||
28 | wantedBy = [ "timers.target" ]; | ||
29 | }; | ||
30 | |||
31 | systemd.user.services.battery-alert = { | ||
32 | description = "Check battery levels"; | ||
33 | path = [ pkgs.libnotify pkgs.coreutils ]; | ||
34 | serviceConfig = { | ||
35 | PassEnvironment = "DISPLAY XAUTHORITY"; | ||
36 | }; | ||
37 | script = '' | ||
38 | bat_status=$( ${pkgs.coreutils}/bin/cat /sys/class/power_supply/BAT0/capacity ) | ||
39 | charging_status=$( ${pkgs.coreutils}/bin/cat /sys/class/power_supply/BAT0/status ) | ||
40 | |||
41 | # if [[ $bat_status -ge 10 ]]; then | ||
42 | ${pkgs.libnotify}/bin/notify-send "Battery low: $bat_status%" "$charging_status" | ||
43 | # fi | ||
44 | ''; | ||
45 | }; | ||
46 | |||
47 | }; | ||
48 | } | ||
diff --git a/services/suspend.nix b/services/suspend.nix index 445446b..35e213a 100644 --- a/services/suspend.nix +++ b/services/suspend.nix | |||
@@ -37,8 +37,8 @@ in | |||
37 | config = mkIf cfg.enable { | 37 | config = mkIf cfg.enable { |
38 | systemd.user.timers."lowbatt" = { | 38 | systemd.user.timers."lowbatt" = { |
39 | description = "check battery level"; | 39 | description = "check battery level"; |
40 | timerConfig.OnBootSec = "1m"; | 40 | timerConfig.OnBootSec = "5m"; |
41 | timerConfig.OnUnitInactiveSec = "1m"; | 41 | timerConfig.OnUnitInactiveSec = "5m"; |
42 | timerConfig.Unit = "lowbatt.service"; | 42 | timerConfig.Unit = "lowbatt.service"; |
43 | wantedBy = [ "timers.target" ]; | 43 | wantedBy = [ "timers.target" ]; |
44 | }; | 44 | }; |
@@ -49,10 +49,10 @@ in | |||
49 | export battery_capacity=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/capacity) | 49 | export battery_capacity=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/capacity) |
50 | export battery_status=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/status) | 50 | export battery_status=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/status) |
51 | if [[ $battery_capacity -le ${builtins.toString cfg.notifyCapacity} && $battery_status = "Discharging" ]]; then | 51 | if [[ $battery_capacity -le ${builtins.toString cfg.notifyCapacity} && $battery_status = "Discharging" ]]; then |
52 | ${pkgs.libnotify}/bin/notify-send --urgency=critical --hint=int:transient:1 --icon=battery_empty "Battery Low" "You should probably plug-in." | 52 | ${pkgs.libnotify}/bin/notify-send --urgency=critical --hint=int:transient:1 --icon=battery_empty "Battery Low: $battery_capacity%" |
53 | fi | 53 | fi |
54 | if [[ $battery_capacity -le ${builtins.toString cfg.suspendCapacity} && $battery_status = "Discharging" ]]; then | 54 | if [[ $battery_capacity -le ${builtins.toString cfg.suspendCapacity} && $battery_status = "Discharging" ]]; then |
55 | ${pkgs.libnotify}/bin/notify-send --urgency=critical --hint=int:transient:1 --icon=battery_empty "Battery Critically Low" "Computer will suspend in 60 seconds." | 55 | ${pkgs.libnotify}/bin/notify-send --urgency=critical --hint=int:transient:1 --icon=battery_empty "Battery Critically Low: $battery_capacity%" |
56 | sleep 60s | 56 | sleep 60s |
57 | battery_status=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/status) | 57 | battery_status=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/status) |
58 | if [[ $battery_status = "Discharging" ]]; then | 58 | if [[ $battery_status = "Discharging" ]]; then |