From dc45bf89a66ec6c8cd25cf5605deb853f6984705 Mon Sep 17 00:00:00 2001
From: neodarz <neodarz@neodarz.net>
Date: Wed, 4 Sep 2019 22:18:18 +0200
Subject: Add systemd dotfiles

---
 README.md                                               |  1 +
 config.yaml                                             |  4 ++++
 dotfiles/config/systemd/user.conf                       |  2 ++
 dotfiles/config/systemd/user/aria2d.service             |  9 +++++++++
 .../systemd/user/default.target.wants/syncthing.service | 17 +++++++++++++++++
 .../systemd/user/default.target.wants/tmux.service      | 17 +++++++++++++++++
 .../systemd/user/default.target.wants/twmnd.service     | 12 ++++++++++++
 dotfiles/config/systemd/user/ssh-agent.service          | 10 ++++++++++
 dotfiles/config/systemd/user/tmux.service               | 17 +++++++++++++++++
 dotfiles/config/systemd/user/twmnd.service              | 12 ++++++++++++
 10 files changed, 101 insertions(+)
 create mode 100644 dotfiles/config/systemd/user.conf
 create mode 100644 dotfiles/config/systemd/user/aria2d.service
 create mode 100644 dotfiles/config/systemd/user/default.target.wants/syncthing.service
 create mode 100644 dotfiles/config/systemd/user/default.target.wants/tmux.service
 create mode 100644 dotfiles/config/systemd/user/default.target.wants/twmnd.service
 create mode 100644 dotfiles/config/systemd/user/ssh-agent.service
 create mode 100644 dotfiles/config/systemd/user/tmux.service
 create mode 100644 dotfiles/config/systemd/user/twmnd.service

diff --git a/README.md b/README.md
index e2c3219..a9f892c 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,7 @@
  aria2          > aria2 deamon
  alacritty      > terminal config
  i3pystatus     > i3 bar window manager replacement config
+ systemd        > user services for differents application
 ```
 # Managing
 
diff --git a/config.yaml b/config.yaml
index 5cd3e64..827ab28 100644
--- a/config.yaml
+++ b/config.yaml
@@ -12,12 +12,16 @@ dotfiles:
   d_aria2:
     src: config/aria2
     dst: ~/.config/aria2
+  d_systemd:
+    src: config/systemd
+    dst: ~/.config/systemd
 profiles:
   unicorn:
     dotfiles:
     - d_i3pystatus
     - d_alacritty
     - d_aria2
+    - d_systemd
   fenec:
     dotfiles:
     - d_i3pystatus
diff --git a/dotfiles/config/systemd/user.conf b/dotfiles/config/systemd/user.conf
new file mode 100644
index 0000000..9f9e7b7
--- /dev/null
+++ b/dotfiles/config/systemd/user.conf
@@ -0,0 +1,2 @@
+[Manager]
+#DefaultEnvironment="XDG_RUNTIME_DIR=/run/user/1000" "XAUTHORITY=/home/neodarz/.Xauthority" "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus"
diff --git a/dotfiles/config/systemd/user/aria2d.service b/dotfiles/config/systemd/user/aria2d.service
new file mode 100644
index 0000000..4980e3a
--- /dev/null
+++ b/dotfiles/config/systemd/user/aria2d.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Aria2 Service
+After=network.target
+
+[Service]
+ExecStart=/usr/bin/aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all --save-session %h/.config/aria2/session.lock --input-file %h/.config/aria2/session.lock --conf-path=%h/.config/aria2/aria2.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dotfiles/config/systemd/user/default.target.wants/syncthing.service b/dotfiles/config/systemd/user/default.target.wants/syncthing.service
new file mode 100644
index 0000000..9b7ed80
--- /dev/null
+++ b/dotfiles/config/systemd/user/default.target.wants/syncthing.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=Syncthing - Open Source Continuous File Synchronization
+Documentation=man:syncthing(1)
+
+[Service]
+ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
+Restart=on-failure
+SuccessExitStatus=3 4
+RestartForceExitStatus=3 4
+
+# Hardening
+SystemCallArchitectures=native
+MemoryDenyWriteExecute=true
+NoNewPrivileges=true
+
+[Install]
+WantedBy=default.target
diff --git a/dotfiles/config/systemd/user/default.target.wants/tmux.service b/dotfiles/config/systemd/user/default.target.wants/tmux.service
new file mode 100644
index 0000000..8a35ce1
--- /dev/null
+++ b/dotfiles/config/systemd/user/default.target.wants/tmux.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=tmux default session (detached)
+Documentation=man:tmux(1)
+
+[Service]
+Type=forking
+Environment=DISPLAY=:0
+ExecStart=/usr/bin/tmux new-session
+
+ExecStop=/home/neodarz/.tmux/plugins/tmux-resurrect/scripts/save.sh
+ExecStop=/usr/bin/tmux kill-server
+KillMode=none
+
+RestartSec=2
+
+[Install]
+WantedBy=default.target
diff --git a/dotfiles/config/systemd/user/default.target.wants/twmnd.service b/dotfiles/config/systemd/user/default.target.wants/twmnd.service
new file mode 100644
index 0000000..355d8ec
--- /dev/null
+++ b/dotfiles/config/systemd/user/default.target.wants/twmnd.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=twmn server
+After=graphical.target
+
+[Service]
+Type=simple
+StandardOutput=null
+Restart=on-failure
+ExecStart=/usr/bin/twmnd
+
+[Install]
+WantedBy=default.target
diff --git a/dotfiles/config/systemd/user/ssh-agent.service b/dotfiles/config/systemd/user/ssh-agent.service
new file mode 100644
index 0000000..9428410
--- /dev/null
+++ b/dotfiles/config/systemd/user/ssh-agent.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=SSH key agent
+
+[Service]
+Type=simple
+Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
+ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
+
+[Install]
+WantedBy=default.target
diff --git a/dotfiles/config/systemd/user/tmux.service b/dotfiles/config/systemd/user/tmux.service
new file mode 100644
index 0000000..8a35ce1
--- /dev/null
+++ b/dotfiles/config/systemd/user/tmux.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=tmux default session (detached)
+Documentation=man:tmux(1)
+
+[Service]
+Type=forking
+Environment=DISPLAY=:0
+ExecStart=/usr/bin/tmux new-session
+
+ExecStop=/home/neodarz/.tmux/plugins/tmux-resurrect/scripts/save.sh
+ExecStop=/usr/bin/tmux kill-server
+KillMode=none
+
+RestartSec=2
+
+[Install]
+WantedBy=default.target
diff --git a/dotfiles/config/systemd/user/twmnd.service b/dotfiles/config/systemd/user/twmnd.service
new file mode 100644
index 0000000..355d8ec
--- /dev/null
+++ b/dotfiles/config/systemd/user/twmnd.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=twmn server
+After=graphical.target
+
+[Service]
+Type=simple
+StandardOutput=null
+Restart=on-failure
+ExecStart=/usr/bin/twmnd
+
+[Install]
+WantedBy=default.target
-- 
cgit v1.2.1