2019-04-04 10:26:43 +02:00
|
|
|
#+TITLE: Systemd
|
|
|
|
|
2019-08-23 09:59:59 +02:00
|
|
|
* Pass Git
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/passgit.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-08-23 09:59:59 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Sync Passwords every day
|
|
|
|
RefuseManualStart=no
|
|
|
|
RefuseManualStop=yes
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
ExecStart=%h/scripts/pass_git_sync.sh
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Timer
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/passgit.timer
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-08-23 09:59:59 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Sync Passwords every day
|
|
|
|
RefuseManualStart=no
|
|
|
|
RefuseManualStop=no
|
|
|
|
Wants=network-online.target
|
|
|
|
After=network.target network-online.target dbus.socket
|
|
|
|
|
|
|
|
[Timer]
|
|
|
|
OnCalendar=*-*-* 17:00:00
|
|
|
|
Persistent=true
|
|
|
|
Unit=passgit.service
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Script
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/scripts/pass_git_sync.sh
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
|
|
:END:
|
2019-08-23 09:59:59 +02:00
|
|
|
|
|
|
|
#+begin_src bash
|
|
|
|
pass git pull --rebase && pass git push
|
|
|
|
#+end_src
|
|
|
|
|
2019-04-04 10:26:43 +02:00
|
|
|
* Buku Git
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/bukugit.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Sync Bookmarks every day
|
|
|
|
RefuseManualStart=no
|
|
|
|
RefuseManualStop=yes
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
2019-04-05 09:28:20 +02:00
|
|
|
ExecStart=%h/scripts/buku_git_push.sh
|
2019-04-04 10:26:43 +02:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Timer
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/bukugit.timer
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Sync All Mails every x hours
|
|
|
|
RefuseManualStart=no
|
|
|
|
RefuseManualStop=no
|
2019-05-02 10:44:57 +02:00
|
|
|
Wants=network-online.target
|
2019-04-04 10:26:43 +02:00
|
|
|
After=network.target network-online.target dbus.socket
|
|
|
|
|
|
|
|
[Timer]
|
|
|
|
OnCalendar=*-*-* 16:00:00
|
|
|
|
Persistent=true
|
|
|
|
Unit=bukugit.service
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Script
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/scripts/buku_git_push.sh
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+begin_src bash
|
|
|
|
cd ~/.local/share/buku/
|
|
|
|
|
|
|
|
if [[ ! -z $(git status -s bookmarks.db) ]]
|
|
|
|
then
|
|
|
|
git add bookmarks.db
|
|
|
|
git commit -m "Changed bookmarks - $(date +%F)"
|
|
|
|
git push
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* Check mail
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/checkmail.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Check new mails
|
|
|
|
RefuseManualStart=no
|
|
|
|
RefuseManualStop=yes
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
2019-07-20 17:25:08 +02:00
|
|
|
ExecStart=%h/scripts/checkmail.sh -q -v
|
2019-04-04 10:26:43 +02:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Timer
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/checkmail.timer
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Check Mail every x minutes
|
|
|
|
RefuseManualStart=no
|
|
|
|
RefuseManualStop=no
|
2019-05-02 10:44:57 +02:00
|
|
|
Wants=network-online.target
|
2019-04-04 10:26:43 +02:00
|
|
|
After=network.target network-online.target dbus.socket
|
|
|
|
Requires=checkmail.service
|
|
|
|
|
|
|
|
[Timer]
|
|
|
|
Persistent=false
|
|
|
|
OnBootSec=2min
|
|
|
|
OnUnitActiveSec=5min
|
|
|
|
AccuracySec=10s
|
|
|
|
Unit=checkmail.service
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Script
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/scripts/checkmail.sh
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+begin_src bash
|
2019-07-20 17:25:08 +02:00
|
|
|
while [ -n "$1" ]; do # while loop starts
|
|
|
|
case "$1" in
|
2019-08-23 10:00:47 +02:00
|
|
|
-a) opt_all='--all' ;; # Check All inboxes
|
2019-07-20 17:25:08 +02:00
|
|
|
-v) opt_verbose='--verbose' ;; # Verbose
|
|
|
|
-q) opt_quiet='--quiet' ;; # Quiet
|
|
|
|
*) echo "Option $1 not recognized" ;; # In case you typed a different option
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2019-04-04 10:26:43 +02:00
|
|
|
# =============================================================
|
|
|
|
# Count number of mails
|
|
|
|
gmail_old="$(ls ~/.mail/gmail/Inbox/new | wc -l)"
|
|
|
|
esrf_old="$(ls ~/.mail/esrf/Inbox/new | wc -l)"
|
|
|
|
ulg_old="$(ls ~/.mail/ulg/Inbox/new | wc -l)"
|
|
|
|
# =============================================================
|
|
|
|
|
|
|
|
# =============================================================
|
|
|
|
# Retreive mails
|
2019-07-20 17:25:08 +02:00
|
|
|
mbsync $opt_all $opt_verbose gmail-Home esrf-Home ulg-Home
|
2019-04-04 10:26:43 +02:00
|
|
|
# =============================================================
|
|
|
|
|
|
|
|
# =============================================================
|
|
|
|
# Count number of mails
|
|
|
|
gmail_new="$(ls ~/.mail/gmail/Inbox/new | wc -l)"
|
|
|
|
esrf_new="$(ls ~/.mail/esrf/Inbox/new | wc -l)"
|
|
|
|
ulg_new="$(ls ~/.mail/ulg/Inbox/new | wc -l)"
|
|
|
|
# =============================================================
|
|
|
|
|
|
|
|
# =============================================================
|
|
|
|
# Total Number of new mails since last checking
|
|
|
|
new="$(($gmail_new+$esrf_new+$ulg_new))"
|
|
|
|
old="$(($gmail_old+$esrf_old+$ulg_old))"
|
|
|
|
# =============================================================
|
|
|
|
|
|
|
|
# =============================================================
|
|
|
|
# Notification
|
|
|
|
if [ "$new" -gt 0 ]; then
|
2019-05-16 21:13:08 +02:00
|
|
|
dunstify --replace=98465 'New mail' " $esrf_new $gmail_new $ulg_new"
|
2019-04-04 10:26:43 +02:00
|
|
|
fi
|
|
|
|
# =============================================================
|
|
|
|
|
|
|
|
# =============================================================
|
|
|
|
# Indexation and Tags
|
|
|
|
# notmuch new
|
2019-07-20 17:25:08 +02:00
|
|
|
mu index --maildir=~/.mail $opt_verbose $opt_quiet
|
2019-04-04 10:26:43 +02:00
|
|
|
# Update on Emacs
|
2019-05-16 21:13:08 +02:00
|
|
|
# if [ "$(($new-$old))" -gt 0 ]; then
|
|
|
|
# emacsclient --eval '(mu4e-update-index)';
|
|
|
|
# fi
|
2019-04-04 10:26:43 +02:00
|
|
|
# =============================================================
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* Sync mail
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/syncmail.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Sync all mails
|
|
|
|
RefuseManualStart=no
|
|
|
|
RefuseManualStop=yes
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
2019-07-20 17:25:08 +02:00
|
|
|
ExecStart=%h/scripts/checkmail.sh -a -q -v
|
2019-04-04 10:26:43 +02:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Timer
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/syncmail.timer
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Sync All Mails every x hours
|
|
|
|
RefuseManualStart=no
|
|
|
|
RefuseManualStop=no
|
2019-05-02 10:44:57 +02:00
|
|
|
Wants=network-online.target
|
2019-04-04 10:26:43 +02:00
|
|
|
After=network.target network-online.target dbus.socket
|
|
|
|
Requires=syncmail.service
|
|
|
|
|
|
|
|
[Timer]
|
|
|
|
Persistent=false
|
|
|
|
OnBootSec=30min
|
|
|
|
OnUnitActiveSec=300min
|
|
|
|
AccuracySec=10s
|
|
|
|
Unit=syncmail.service
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Emacs
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/emacs.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
#+BEGIN_SRC conf
|
|
|
|
[Unit]
|
|
|
|
Description=Emacs text editor
|
|
|
|
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
|
|
|
|
|
|
|
|
[Service]
|
2019-05-16 21:13:08 +02:00
|
|
|
Type=forking
|
|
|
|
ExecStart=/usr/bin/emacs --daemon
|
2019-04-04 10:26:43 +02:00
|
|
|
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
|
|
|
|
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
|
|
|
|
Restart=on-failure
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+END_SRC
|
2019-04-10 16:57:25 +02:00
|
|
|
|
2019-04-04 10:26:43 +02:00
|
|
|
* Vdirsyncer
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/vdirsyncer.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
|
|
|
|
2019-04-04 10:26:43 +02:00
|
|
|
#+begin_src conf
|
|
|
|
[Unit]
|
|
|
|
Description=Synchronize calendars and contacts
|
|
|
|
Documentation=https://vdirsyncer.readthedocs.org/
|
2019-05-02 10:44:57 +02:00
|
|
|
Wants=network-online.target
|
|
|
|
After=network.target network-online.target
|
2019-04-04 10:26:43 +02:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
ExecStart=/usr/bin/vdirsyncer sync
|
|
|
|
Type=oneshot
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Timer
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/vdirsyncer.timer
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
|
|
|
|
2019-04-04 10:26:43 +02:00
|
|
|
#+begin_src conf
|
|
|
|
[Unit]
|
|
|
|
Description=Synchronize vdirs
|
|
|
|
|
|
|
|
[Timer]
|
|
|
|
OnBootSec=5m
|
|
|
|
OnUnitActiveSec=15m
|
|
|
|
AccuracySec=5m
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=timers.target
|
|
|
|
#+end_src
|
2019-05-16 21:13:08 +02:00
|
|
|
|
2019-04-10 16:57:25 +02:00
|
|
|
* Weechat
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/weechat.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-04-10 16:57:25 +02:00
|
|
|
#+begin_src conf
|
|
|
|
[Unit]
|
|
|
|
Description=A WeeChat client and relay service using Tmux
|
2019-05-02 10:44:57 +02:00
|
|
|
Wants=network-online.target
|
|
|
|
After=network.target network-online.target
|
2019-04-10 16:57:25 +02:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=forking
|
|
|
|
ExecStart=/usr/bin/tmux -L weechat new -d -s weechat weechat
|
|
|
|
ExecStop=/usr/bin/tmux -L weechat kill-session -t weechat
|
2019-05-02 10:44:57 +02:00
|
|
|
Restart=always
|
|
|
|
RestartSec=3
|
2019-04-10 16:57:25 +02:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+end_src
|
2019-06-22 17:19:38 +02:00
|
|
|
|
2019-05-02 10:44:57 +02:00
|
|
|
* Neomutt
|
|
|
|
** Service
|
2019-12-15 10:57:23 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/neomutt.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-05-02 10:44:57 +02:00
|
|
|
#+begin_src conf
|
|
|
|
[Unit]
|
|
|
|
Description=Neomutt - mail client
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=forking
|
|
|
|
ExecStart=/usr/bin/tmux -L neomutt new -d -s neomutt neomutt
|
|
|
|
ExecStop=/usr/bin/tmux -L neomutt kill-session -t neomutt
|
|
|
|
Restart=always
|
|
|
|
RestartSec=3
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+end_src
|
2019-06-22 17:19:38 +02:00
|
|
|
|
2019-05-02 10:44:57 +02:00
|
|
|
* Powertop
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/powertop.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
2019-05-02 10:44:57 +02:00
|
|
|
#+begin_src conf
|
|
|
|
[Unit]
|
|
|
|
Description=Powertop tunings
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
ExecStart=/usr/bin/powertop --auto-tune
|
|
|
|
RemainAfterExit=true
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
#+end_src
|
2019-05-16 21:13:08 +02:00
|
|
|
* NCMPCPP
|
|
|
|
** Service
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/ncmpcpp.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
|
|
|
|
2019-05-16 21:13:08 +02:00
|
|
|
#+begin_src conf
|
|
|
|
[Unit]
|
|
|
|
Description=Ncmpcpp - Music Player
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=forking
|
|
|
|
ExecStart=/usr/bin/tmux -L ncmpcpp new -d -s ncmpcpp ncmpcpp
|
|
|
|
ExecStop=/usr/bin/tmux -L ncmpcpp kill-session -t ncmpcpp
|
|
|
|
Restart=always
|
|
|
|
RestartSec=3
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* Newsboat
|
|
|
|
** Service - tmux
|
2019-12-16 08:53:36 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/.config/systemd/user/newsboat.service
|
|
|
|
:header-args+: :comments both :mkdirp yes
|
|
|
|
:END:
|
|
|
|
|
2019-05-16 21:13:08 +02:00
|
|
|
#+begin_src conf
|
|
|
|
[Unit]
|
|
|
|
Description=Newsboat - RSS reader
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=forking
|
|
|
|
ExecStart=/usr/bin/tmux -L newsboat new -d -s newsboat newsboat
|
|
|
|
ExecStop=/usr/bin/tmux -L newsboat kill-session -t newsboat
|
|
|
|
Restart=always
|
|
|
|
RestartSec=3
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
#+end_src
|