aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-09-26 16:56:36 +0100
committerAkshay <[email protected]>2021-09-26 16:56:36 +0100
commit5cdb4e421a809de51c3ebe8404e50d732721238b (patch)
tree73b71617c41b3e13edbf26035e821bb884d30441 /services
init
Diffstat (limited to 'services')
-rw-r--r--services/battery.nix48
-rw-r--r--services/default.nix27
-rw-r--r--services/dunst.nix71
-rw-r--r--services/mbsync.nix11
-rw-r--r--services/picom.nix18
-rw-r--r--services/redshift.nix18
-rw-r--r--services/suspend.nix65
-rw-r--r--services/sxhkd.nix17
8 files changed, 275 insertions, 0 deletions
diff --git a/services/battery.nix b/services/battery.nix
new file mode 100644
index 0000000..a871e8f
--- /dev/null
+++ b/services/battery.nix
@@ -0,0 +1,48 @@
1{ config, lib, pkgs, ... }:
2
3with lib;
4let
5 cfg = config.services.battery-alert;
6 bat = pkgs.writeScriptBin "bat"
7 ''
8 '';
9in
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/default.nix b/services/default.nix
new file mode 100644
index 0000000..0e85cd9
--- /dev/null
+++ b/services/default.nix
@@ -0,0 +1,27 @@
1{ config
2, pkgs
3, theme
4, ...
5}:
6
7{
8
9 imports = [
10 ./dunst.nix
11 ./picom.nix
12 ./redshift.nix
13 ./sxhkd.nix
14 ./mbsync.nix
15 ];
16
17 services = {
18 lorri.enable = true;
19 gpg-agent = {
20 enable = true;
21 defaultCacheTtl = 86400;
22 maxCacheTtl = 86400;
23 pinentryFlavor = "curses";
24 };
25 };
26
27}
diff --git a/services/dunst.nix b/services/dunst.nix
new file mode 100644
index 0000000..8882ade
--- /dev/null
+++ b/services/dunst.nix
@@ -0,0 +1,71 @@
1{ config
2, pkgs
3, theme
4, ...
5}:
6
7with theme;
8{
9 services.dunst = {
10 enable = true;
11 settings = {
12 global = {
13 font = "Input 9";
14 allow_markup = "no";
15 format = "%s\n%b";
16 sort = "yes";
17 indicate_hidden = "yes";
18 alignment = "right";
19 bounce_freq = "0";
20 show_age_threshold = "60";
21 word_wrap = "yes";
22 ignore_newline = "no";
23 geometry = "300x8-20+20";
24 shrink = "yes";
25 transparency = "0";
26 idle_threshold = "120";
27 monitor = "0";
28 follow = "mouse";
29 sticky_history = "yes";
30 history_length = "20";
31 show_indicators = "yes";
32 line_height = "0";
33 separator_height = "0";
34 padding = "20";
35 horizontal_padding = "20";
36 separator_color = "auto";
37 startup_notification = "true";
38 };
39
40 urgency_normal = {
41 background = base00;
42 foreground = base05;
43 timeout = 10;
44 };
45
46 urgency_low = {
47 background = base00;
48 foreground = base05;
49 timeout = 2;
50 };
51
52 urgency_critical = {
53 background = base00;
54 foreground = base05;
55 timeout = 0;
56 };
57
58 frame = {
59 width = 2;
60 color = base01;
61 };
62
63 shortcuts = {
64 close = "ctrl+space";
65 close_all = "ctrl+shift+space";
66 history = "ctrl+grave";
67 context = "ctrl+shift+period";
68 };
69 };
70 };
71}
diff --git a/services/mbsync.nix b/services/mbsync.nix
new file mode 100644
index 0000000..168b7ec
--- /dev/null
+++ b/services/mbsync.nix
@@ -0,0 +1,11 @@
1{ config
2, pkgs
3, ...
4}:
5
6{
7 services.mbsync = {
8 enable = true;
9 frequency = "*:0/15";
10 };
11}
diff --git a/services/picom.nix b/services/picom.nix
new file mode 100644
index 0000000..67605d1
--- /dev/null
+++ b/services/picom.nix
@@ -0,0 +1,18 @@
1{ config
2, pkgs
3, ...
4}:
5
6{
7 services.picom = {
8 enable = true;
9 backend = "glx";
10 fade = true;
11 fadeDelta = 10;
12 fadeSteps = [ "0.04" "0.04" ];
13 inactiveDim = "0.0";
14 shadow = false;
15 shadowOffsets = [ (-60) (-60) ];
16 shadowOpacity = "0.20";
17 };
18}
diff --git a/services/redshift.nix b/services/redshift.nix
new file mode 100644
index 0000000..5385fc1
--- /dev/null
+++ b/services/redshift.nix
@@ -0,0 +1,18 @@
1{ config
2, pkgs
3, ...
4}:
5
6{
7 services.redshift = {
8 enable = true;
9 temperature = {
10 day = 5000;
11 night = 4000;
12 };
13 tray = false;
14 provider = "manual";
15 latitude = "12";
16 longitude = "77";
17 };
18}
diff --git a/services/suspend.nix b/services/suspend.nix
new file mode 100644
index 0000000..445446b
--- /dev/null
+++ b/services/suspend.nix
@@ -0,0 +1,65 @@
1{ config, lib, pkgs, ... }:
2
3with lib;
4let
5 cfg = config.services.batteryNotifier;
6in
7{
8 options = {
9 services.batteryNotifier = {
10 enable = mkOption {
11 default = false;
12 description = ''
13 Whether to enable battery notifier.
14 '';
15 };
16 device = mkOption {
17 default = "BAT0";
18 description = ''
19 Device to monitor.
20 '';
21 };
22 notifyCapacity = mkOption {
23 default = 10;
24 description = ''
25 Battery level at which a notification shall be sent.
26 '';
27 };
28 suspendCapacity = mkOption {
29 default = 5;
30 description = ''
31 Battery level at which a suspend unless connected shall be sent.
32 '';
33 };
34 };
35 };
36
37 config = mkIf cfg.enable {
38 systemd.user.timers."lowbatt" = {
39 description = "check battery level";
40 timerConfig.OnBootSec = "1m";
41 timerConfig.OnUnitInactiveSec = "1m";
42 timerConfig.Unit = "lowbatt.service";
43 wantedBy = [ "timers.target" ];
44 };
45 systemd.user.services."lowbatt" = {
46 description = "battery level notifier";
47 serviceConfig.PassEnvironment = "DISPLAY";
48 script = ''
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)
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."
53 fi
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."
56 sleep 60s
57 battery_status=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/status)
58 if [[ $battery_status = "Discharging" ]]; then
59 systemctl suspend
60 fi
61 fi
62 '';
63 };
64 };
65}
diff --git a/services/sxhkd.nix b/services/sxhkd.nix
new file mode 100644
index 0000000..8658875
--- /dev/null
+++ b/services/sxhkd.nix
@@ -0,0 +1,17 @@
1{ config
2, pkgs
3, theme
4, ...
5}:
6
7{
8 services.sxhkd = {
9 enable = true;
10 keybindings = {
11 "XF86Audio{Lower,Raise}Volume" = "${pkgs.alsaUtils}/bin/amixer sset Master 2%{-,+}";
12 "XF86AudioMute" = "${pkgs.alsaUtils}/bin/amixer sset Master toggle";
13 "XF86MonBrightness{Down,Up}" = "${pkgs.light}/bin/light -{U,A} 5";
14 "super + Escape" = "pkill -USR1 -x sxhkd";
15 };
16 };
17}