From e0f8aaa755eda1fd65dbe5f330c3cdffacf97cc7 Mon Sep 17 00:00:00 2001
From: kraem <ebrin.ronnie@protonmail.com>
Date: Sun, 18 Sep 2022 22:53:08 +0200
Subject: [PATCH] nixos/ydotool: module init

---
 nixos/modules/module-list.nix                 |  1 +
 nixos/modules/programs/ydotool.nix            | 29 +++++++++++++++++++
 4 files changed, 39 insertions(+)
 create mode 100644 nixos/modules/programs/ydotool.nix

diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index dce6e878540d5..580d938030685 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -280,6 +280,7 @@
   ./programs/xwayland.nix
   ./programs/yabar.nix
   ./programs/yazi.nix
+  ./programs/ydotool.nix
   ./programs/yubikey-touch-detector.nix
   ./programs/zsh/zmap.nix
   ./programs/zsh/oh-my-zsh.nix
diff --git a/nixos/modules/programs/ydotool.nix b/nixos/modules/programs/ydotool.nix
new file mode 100644
index 0000000000000..f5996059a4c36
--- /dev/null
+++ b/nixos/modules/programs/ydotool.nix
@@ -0,0 +1,29 @@
+{ config, lib, pkgs, ... }:
+
+let
+  cfg = config.programs.ydotool;
+in
+
+{
+
+  options = {
+    programs.ydotool = {
+      enable = lib.mkEnableOption (lib.mdDoc "ydotool, a generic Linux command-line automation tool");
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+
+    environment.systemPackages = [ pkgs.ydotool ];
+
+    systemd.user.services.ydotoold = {
+      description = "Starts ydotoold service";
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        ExecStart = "${pkgs.ydotool}/bin/ydotoold -p $XDG_RUNTIME_DIR/ydotoold.sock";
+        Restart = "always";
+      };
+    };
+  };
+}
+
