Add login.d - and cleanup install.sh
This commit is contained in:
parent
b77c0b22f1
commit
fe6fd82ecc
49
etc/systemd/logind.conf
Normal file
49
etc/systemd/logind.conf
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# This file is part of systemd.
|
||||||
|
#
|
||||||
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
|
# the logind.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
|
#
|
||||||
|
# Use 'systemd-analyze cat-config systemd/logind.conf' to display the full config.
|
||||||
|
#
|
||||||
|
# See logind.conf(5) for details.
|
||||||
|
|
||||||
|
[Login]
|
||||||
|
#NAutoVTs=6
|
||||||
|
#ReserveVT=6
|
||||||
|
#KillUserProcesses=no
|
||||||
|
#KillOnlyUsers=
|
||||||
|
#KillExcludeUsers=root
|
||||||
|
#InhibitDelayMaxSec=5
|
||||||
|
#UserStopDelaySec=10
|
||||||
|
HandlePowerKey=suspend
|
||||||
|
#HandlePowerKeyLongPress=ignore
|
||||||
|
#HandleRebootKey=reboot
|
||||||
|
#HandleRebootKeyLongPress=poweroff
|
||||||
|
#HandleSuspendKey=suspend
|
||||||
|
#HandleSuspendKeyLongPress=hibernate
|
||||||
|
#HandleHibernateKey=hibernate
|
||||||
|
#HandleHibernateKeyLongPress=ignore
|
||||||
|
HandleLidSwitch=suspend
|
||||||
|
HandleLidSwitchExternalPower=suspend
|
||||||
|
#HandleLidSwitchDocked=ignore
|
||||||
|
#PowerKeyIgnoreInhibited=no
|
||||||
|
#SuspendKeyIgnoreInhibited=no
|
||||||
|
#HibernateKeyIgnoreInhibited=no
|
||||||
|
#LidSwitchIgnoreInhibited=yes
|
||||||
|
#RebootKeyIgnoreInhibited=no
|
||||||
|
#HoldoffTimeoutSec=30s
|
||||||
|
#IdleAction=ignore
|
||||||
|
#IdleActionSec=30min
|
||||||
|
#RuntimeDirectorySize=10%
|
||||||
|
#RuntimeDirectoryInodesMax=
|
||||||
|
#RemoveIPC=yes
|
||||||
|
#InhibitorsMax=8192
|
||||||
|
#SessionsMax=8192
|
||||||
|
#StopIdleSessionSec=infinity
|
188
install.sh
188
install.sh
@ -1,92 +1,138 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
set -eu
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
cd "${SCRIPT_DIR}"
|
||||||
|
|
||||||
run_as_user() {
|
function run_as_user() {
|
||||||
echo "Run with user $1: ${@:2}"
|
echo "Run with user $1:" "${@:2}"
|
||||||
sudo -u "$@"
|
sudo -u "${@}"
|
||||||
}
|
}
|
||||||
set -e
|
|
||||||
link_with_bkp() {
|
function user_of_file() {
|
||||||
SRC=$2
|
local path;
|
||||||
DEST=$3
|
path="$(realpath -s -m "$1")"
|
||||||
USER=$1
|
while [ ! -e "${path}" ]; do
|
||||||
if [ -d "$DEST" ]; then
|
path="$(dirname "${path}")"
|
||||||
DEST="$DEST/$(basename "$SRC")"
|
done
|
||||||
|
stat -c '%U' "${path}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function fatal() {
|
||||||
|
echo "${@}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function backup_file() {
|
||||||
|
|
||||||
|
local i=0
|
||||||
|
local dest
|
||||||
|
local file="$1"
|
||||||
|
if [[ -e "${file}" ]]; then
|
||||||
|
while true; do
|
||||||
|
dest="${file}.old.${i}"
|
||||||
|
if [[ ! -e "${dest}" ]]; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
i=$(("${i}" + 1))
|
||||||
|
done
|
||||||
|
echo "Backing up '${file}' to '${dest}'"
|
||||||
|
run_as_user "$(user_of_file "${file}")" mv "${file}" "${dest}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install() {
|
||||||
|
local root=""
|
||||||
|
local dst=""
|
||||||
|
local user=""
|
||||||
|
local OPTIND
|
||||||
|
while getopts "u:d:p:r" o; do
|
||||||
|
case "${o}" in
|
||||||
|
u)
|
||||||
|
user="${OPTARG}"
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
root="${OPTARG}"
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
dst="${OPTARG}"
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
root="/"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown arg '${o}'"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
local src="$1"
|
||||||
|
|
||||||
|
if [[ -n "${dst}" ]] && [[ -n "${root}" ]]; then
|
||||||
|
fatal "Only one of -r or -p can be used at a time"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$SRC" ]; then
|
if [[ -z "${dst}" ]] && [[ -z "${root}" ]]; then
|
||||||
echo "$SRC is not a file";
|
root="${HOME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${root}" ]]; then
|
||||||
|
dst="${root}/${src}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dst=$(realpath -ms "${dst}")
|
||||||
|
src=$(realpath -ms "${src}")
|
||||||
|
|
||||||
|
if [[ -z "${user}" ]]; then
|
||||||
|
user="$(user_of_file "${dst}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${user}: ${src} => ${dst}"
|
||||||
|
|
||||||
|
if [ ! -f "${src}" ] && [ ! -d "${src}" ]; then
|
||||||
|
echo "${src} is not a file";
|
||||||
return 1;
|
return 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$DEST" ] || [ -L "$DEST" ]; then
|
if [ -e "${dst}" ] || [ -L "${dst}" ]; then
|
||||||
if [ "$SRC" -ef "$(readlink "$DEST")" ]; then
|
if [ "${src}" -ef "$(readlink "${dst}")" ]; then
|
||||||
echo "$DEST is correctly linked"
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ -f "$DEST.old" ]; then
|
|
||||||
echo "$DEST.old exists. Cannot create backup."
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
echo "$DEST will be moved to $DEST.old"
|
|
||||||
run_as_user "$USER" mv "$DEST" "$DEST.old"
|
|
||||||
fi
|
fi
|
||||||
echo "$DEST will now be linked."
|
|
||||||
run_as_user "$USER" ln -s "$SRC" "$DEST"
|
backup_file "${dst}"
|
||||||
|
echo "${dst} will now be linked."
|
||||||
|
run_as_user "${user}" ln -s "${src}" "${dst}"
|
||||||
}
|
}
|
||||||
|
|
||||||
terminal_only="\
|
|
||||||
.oh-my-zsh/themes/oke.zsh-theme \
|
|
||||||
.zshrc \
|
|
||||||
.vimrc
|
|
||||||
.winfo.sh"
|
|
||||||
|
|
||||||
workstation="\
|
mode="${1-terminal}"
|
||||||
.config/i3/config \
|
|
||||||
.config/i3status-rust/config.toml \
|
|
||||||
.config/Code/User/settings.json \
|
|
||||||
.config/Code/User/keybindings.json \
|
|
||||||
.Xmodmap \
|
|
||||||
.Xresources \
|
|
||||||
.xinitrc \
|
|
||||||
.mod_keys.sh \
|
|
||||||
.clear_red.sh \
|
|
||||||
etc/modprobe.d/nobeep.conf:/:root \
|
|
||||||
etc/acpi/handler.sh:/:root \
|
|
||||||
etc/acpi/toggle_mute.sh:/:root \
|
|
||||||
etc/acpi/volume.sh:/:root \
|
|
||||||
usr/share/X11/xorg.conf.d/40-libinput.conf:/:root"
|
|
||||||
|
|
||||||
mode="$1"
|
install -d "${HOME}/.dotfiles" "./"
|
||||||
|
|
||||||
if [[ "$mode" =~ "all" ]]; then
|
if [[ $mode =~ "terminal" ]] || [[ $mode =~ "workstation" ]] || [[ $mode =~ "all" ]]; then
|
||||||
mode="workstation terminal"
|
install .oh-my-zsh/themes/oke.zsh-theme
|
||||||
|
install .zshrc
|
||||||
|
install .vimrc
|
||||||
|
install .winfo.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
files=""
|
if [[ $mode =~ "workstation" ]] || [[ $mode =~ "all" ]]; then
|
||||||
|
install .config/i3/config
|
||||||
if [[ $mode =~ "terminal" ]]; then
|
install .config/i3status-rust/config.toml
|
||||||
files="$files $terminal_only"
|
install .config/Code/User/settings.json
|
||||||
|
install .config/Code/User/keybindings.json
|
||||||
|
install .Xmodmap
|
||||||
|
install .Xresources
|
||||||
|
install .xinitrc
|
||||||
|
install -r etc/modprobe.d/nobeep.conf
|
||||||
|
install -r etc/systemd/logind.conf
|
||||||
|
install -r etc/acpi/handler.sh
|
||||||
|
install -r etc/acpi/toggle_mute.sh
|
||||||
|
install -r etc/acpi/volume.sh
|
||||||
|
install -r usr/share/X11/xorg.conf.d/40-libinput.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $mode =~ "workstation" ]]; then
|
|
||||||
files="$files $workstation"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for f in $files; do
|
|
||||||
BASE="$HOME/"
|
|
||||||
USER=$(whoami)
|
|
||||||
if [[ "$f" =~ ":" ]]; then
|
|
||||||
BASE=$(echo "$f" | cut -f2 -d:)
|
|
||||||
USER=$(echo "$f" | cut -f3 -d:)
|
|
||||||
f=$(echo "$f" | cut -f1 -d:)
|
|
||||||
fi
|
|
||||||
dir="$BASE$(dirname $f)"
|
|
||||||
if [ ! -d $dir ]; then
|
|
||||||
run_as_user $USER mkdir -p "$dir"
|
|
||||||
fi
|
|
||||||
link_with_bkp $USER $SCRIPT_DIR/$f $BASE$f
|
|
||||||
done
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user