carbs

Cem's Auto Rice Bootstrapping Scripts
git clone git://git.ckyln.com/carbs.git
Log | Files | Refs | README | LICENSE

commit 999892207b3b41191dc4d2d7be5462dfade2f30c
parent 0cfb5678bf75e17674825b0a1c000b5f274fdc1a
Author: Cem Keylan <cem@ckyln.com>
Date:   Thu, 17 Oct 2019 14:09:51 +0300

configure systemd service for lockme

Diffstat:
Apost-install/lockme.sh | 47+++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+), 0 deletions(-)

diff --git a/post-install/lockme.sh b/post-install/lockme.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +## CARBS, Cem's Auto-Rice Bootstrapping Script +## Copyright (C) 2019 Cem Keylan <cem@ckyln.com> + +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see <https://www.gnu.org/licenses/>. + + +out() { printf "$1\\n"; } +error() { out "==> ERROR: $@"; } >&2 +warning() { out "==> WARNING: $@"; } >&2 +msg() { out "==> $@"; } +msg2() { out " -> $@";} +die() { error "$@"; exit 1; } + + +[ "$HOME" = "$1" ] || die "Not continuing because target directory is different than HOME directory" +[ -e $HOME/.local/bin/lockme ] || die "Could not find lockme, exiting" + +cat <<EOF | sudo tee /etc/systemd/system/lockme.service >/dev/null +[Unit] +Description=Lock X session using lockme +Before=sleep.target + +[Service] +User=$USER +Environment=DISPLAY=:0 +ExecStart=$HOME/.local/bin/lockme + +[Install] +WantedBy=sleep.target + +EOF +sudo systemctl daemon-reload || die "There was an error while reloading daemon" +sudo systemctl enable lockme.service || die "Could not enable lockme service" +msg "Created systemd service for lockme"