Compare commits

..

8 Commits

36 changed files with 249 additions and 200 deletions

View File

@@ -33,9 +33,8 @@ screen:
workspace:
environment:
MACHINE_TYPE: "workstation"
MACHINE_HAS_KEEPASSX: "false"
MACHINE_HAS_NEXTCLOUD: "true"
MACHINE_HAS_RESTIC_BACKUP: "false"
MACHINE_HAS_SPOTIFY: "true"
MACHINE_HAS_TOUCHPAD: "false"
MACHINE_DEFAULT_SCREENPROFILE: "ares"

View File

@@ -48,7 +48,6 @@ workspace:
10: pim
environment:
MACHINE_TYPE: "laptop"
MACHINE_HAS_KEEPASSX: "true"
MACHINE_HAS_RESTIC_BACKUP: "true"
MACHINE_HAS_SPOTIFY: "true"
MACHINE_HAS_TOUCHPAD: "true"

View File

@@ -1,166 +0,0 @@
#!/usr/bin/env bash
set -o nounset
# set -x
selective=0
if (( $# > 0 )) ; then
selective=1
services=("${@}")
fi
do_run() {
name="$1"
shift
run=0
if (( $selective )) ; then
for s in "${services[@]}" ; do
if [[ "$s" == "$name" ]] ; then
run=1
fi
done
else
run=1
fi
return $(( ! $run ))
}
get_unit_name() {
name="$1" ; shift
printf 'user:%s' "${name}"
}
run_raw() {
name="$1"
shift
do_run "$name" || return
systemd-run \
--user \
--unit "$(get_unit_name "${name}")" \
--no-block \
--remain-after-exit \
--setenv=DISPLAY=${DISPLAY} \
"${@}"
}
run() {
name="$1"
shift
run_raw "$name" --property=Restart=always "${@}"
}
run_oneshot_multiple() {
name="$1"
shift
cmd=()
# hacky way to start two processes in oneshot mode
for c in "${@}" ; do
cmd+=(--property "ExecStart=/usr/bin/env ${c}")
done
cmd+=(true)
run_oneshot "$name" "${cmd[@]}"
}
run_oneshot() {
name="$1"
shift
run_raw "$name" --service-type=oneshot "${@}"
}
schedule() {
name="$1"; shift
do_run "$name" || return
systemd-run \
--user \
--unit "$(get_unit_name "${name}")" \
--no-block \
--setenv=DISPLAY=${DISPLAY} \
"${@}"
}
# wallpaper config
wallpaper="$LIBDIR/wallpaper/current"
# keyboard settings
keyboard_layout=de
keyboard_variant=nodeadkeys
keyboard_repeat_delay=150
keyboard_repeat_speed=50
run_oneshot acpi bash -c 'grep "^${ACPI_LID_NAME}.*enabled" /proc/acpi/wakeup && echo " ${ACPI_LID_NAME}" | sudo tee /proc/acpi/wakeup'
run_oneshot xresources xrdb -merge -I${HOME} ~/.Xresources
run_oneshot_multiple keyboard \
"setxkbmap -layout $keyboard_layout -variant $keyboard_variant" \
"xset r rate $keyboard_repeat_delay $keyboard_repeat_speed"
if [[ "${MACHINE_HAS_TOUCHPAD}" == "true" ]] ; then
run_oneshot_multiple touchpad \
"synclient VertEdgeScroll=0" \
"synclient VertTwoFingerScroll=1" \
"synclient MaxSpeed=2.2" \
"synclient AccelFactor=0.08" \
"synclient TapButton1=1" \
"synclient CoastingSpeed=0" \
"synclient PalmDetect=1" \
"synclient PalmMinWidth=20" \
"synclient PalmMinZ=180"
fi
run gpg-agent gpg-agent --homedir "$HOME/.gnupg" --no-detach --daemon
# run gnome-keyring_user gnome-keyring-daemon --start --components pkcs11,secrets --foreground
run kwallet kwalletd5
# a service called dunst already exists and conflicts
run dunst dunst -config ~/.config/dunstrc
# disabled due to firefox flicker
# run compton compton --backend glx --vsync opengl --no-dock-shadow --no-dnd-shadow
schedule wallpaper --on-active=1s --on-calendar hourly \
setrandom --recursive --onlylarge --mode=stretch /usr/share/wallpapers
run blueman blueman-applet
run nm-applet nm-applet
run pasystray pasystray
# redshift unit already exists
run redshift redshift-gtk -c ~/.config/redshift.conf
run yubikey-touch-detector yubikey-touch-detector -libnotify
if [[ "${MACHINE_DEFAULT_SCREENPROFILE}" ]] ; then
run screencfg "$HOME/.screencfg/${MACHINE_DEFAULT_SCREENPROFILE}.sh"
fi
if [[ "${MACHINE_HAS_KEEPASSX}" == "true" ]] ; then
run keepassx keepassx --keyfile ~/.secret/main.key ~/.secret/main.kdbx
fi
if [[ "${MACHINE_HAS_SPOTIFY}" == "true" ]] ; then
run spotify spotify
fi
if [[ "${MACHINE_HAS_NEXTCLOUD}" == "true" ]] ; then
run nextcloud nextcloud --background
fi
if [[ "${MACHINE_HAS_RESTIC_BACKUP}" == "true" ]] ; then
[[ -x ~/bin/restic-backup ]] && schedule restic-backup --on-calendar "Mon..Fri 12:00:00" --on-calendar "Mon..Fri 09:00:00" --on-calendar "Mon..Fri 16:00:00" ~/bin/restic-backup
fi
run firefox firefox -P default

View File

@@ -0,0 +1,19 @@
[Unit]
Wants=blueman.service
Wants=dunst.service
Wants=firefox.service
Wants=gpg-agent.service
Wants=keepassx.service
Wants=keyboard.service
Wants=laptop-lid.service
Wants=nextcloud.service
Wants=nm-applet.service
Wants=pasystray.service
Wants=redshift.service
Wants=restic.timer
Wants=screencfg.service
Wants=spotify.service
Wants=touchpad.service
Wants=wallpaper.timer
Wants=xresources.service
Wants=yubikey-touch-detector.service

View File

@@ -0,0 +1,5 @@
[Unit]
BindsTo=autostart.target
[Service]
ExecStart=/usr/bin/blueman-applet

View File

@@ -0,0 +1,5 @@
[Unit]
BindsTo=autostart.target
[Service]
ExecStart=/usr/bin/dunst -config %h/.config/dunstrc

View File

@@ -0,0 +1,5 @@
[Unit]
BindsTo=autostart.target
[Service]
ExecStart=/usr/bin/firefox --setDefaultBrowser -P default

View File

@@ -0,0 +1,6 @@
[Unit]
BindsTo=autostart.target
[Service]
Type=forking
ExecStart=/usr/bin/gpg-agent --homedir %h/.gnupg --no-detach --daemon

View File

@@ -0,0 +1,6 @@
[Unit]
BindsTo=autostart.target
ConditionEnvironment=MACHINE_HAS_KEEPASSX=true
[Service]
ExecStart=/usr/bin/keepassx --keyfile %h/.secret/main.key %h/.secret/main.kdbx

View File

@@ -0,0 +1,8 @@
[Unit]
BindsTo=autostart.target
[Service]
Type=oneshot
ExecStart=/usr/bin/setxkbmap -layout de -variant nodeadkeys
ExecStart=/usr/bin/xset r rate 150 50
RemainAfterExit=true

View File

@@ -0,0 +1,7 @@
[Unit]
BindsTo=autostart.target
ConditionEnvironment=MACHINE_TYPE=laptop
[Service]
ExecStart=/usr/bin/bash -c 'grep "^${ACPI_LID_NAME}.*enabled" /proc/acpi/wakeup && echo " ${ACPI_LID_NAME}" | sudo tee /proc/acpi/wakeup'

View File

@@ -0,0 +1,7 @@
[Unit]
BindsTo=autostart.target
ConditionEnvironment=MACHINE_HAS_NEXTCLOUD=true
[Service]
ExecStart=/usr/bin/nextcloud --background

View File

@@ -0,0 +1,5 @@
[Unit]
BindsTo=autostart.target
[Service]
ExecStart=/usr/bin/nm-applet

View File

@@ -0,0 +1,5 @@
[Unit]
BindsTo=autostart.target
[Service]
ExecStart=/usr/bin/pasystray

View File

@@ -0,0 +1,5 @@
[Unit]
BindsTo=autostart.target
[Service]
ExecStart=/usr/bin/redshift-gtk -c %h/.config/redshift.conf

View File

@@ -0,0 +1,7 @@
[Unit]
ConditionEnvironment=MACHINE_HAS_RESTIC_BACKUP=true
[Service]
Type=oneshot
ExecStart=%h/bin/restic-backup
RemainAfterExit=true

View File

@@ -0,0 +1,7 @@
[Unit]
BindsTo=autostart.target
[Timer]
OnCalendar=Mon..Fri 09:00:00
OnCalendar=Mon..Fri 12:00:00
OnCalendar=Mon..Fri 16:00:00

View File

@@ -0,0 +1,12 @@
[Unit]
BindsTo=autostart.target
ConditionEnvironment=MACHINE_DEFAULT_SCREENPROFILE
[Service]
Type=oneshot
# systemd.service(5):
# > The command to execute may contain spaces, but control characters are not
# > allowed.
ExecStart=bash -c '%h/.screencfg/${MACHINE_DEFAULT_SCREENPROFILE}.sh'
RemainAfterExit=true

View File

@@ -0,0 +1,5 @@
[Unit]
BindsTo=autostart.target
[Service]
ExecStart=/usr/bin/spotify

View File

@@ -0,0 +1,16 @@
[Unit]
BindsTo=autostart.target
ConditionEnvironment=MACHINE_TYPE=laptop
[Service]
Type=oneshot
ExecStart=/usr/bin/synclient VertEdgeScroll=0
ExecStart=/usr/bin/synclient VertTwoFingerScroll=1
ExecStart=/usr/bin/synclient MaxSpeed=2.2
ExecStart=/usr/bin/synclient AccelFactor=0.08
ExecStart=/usr/bin/synclient TapButton1=1
ExecStart=/usr/bin/synclient CoastingSpeed=0
ExecStart=/usr/bin/synclient PalmDetect=1
ExecStart=/usr/bin/synclient PalmMinWidth=20
ExecStart=/usr/bin/synclient PalmMinZ=1
RemainAfterExit=true

View File

@@ -0,0 +1,4 @@
[Service]
Type=oneshot
ExecStart=/usr/bin/setrandom --recursive --onlylarge --mode=stretch /usr/share/wallpapers
RemainAfterExit=true

View File

@@ -0,0 +1,8 @@
[Unit]
BindsTo=autostart.target
[Timer]
OnActiveSec=0s
OnCalendar=hourly
Unit=wallpaper.service
RemainAfterElapse=true

View File

@@ -0,0 +1,7 @@
[Unit]
BindsTo=autostart.target
[Service]
Type=oneshot
ExecStart=/usr/bin/xrdb -merge -I%h %h/.Xresources
RemainAfterExit=true

View File

@@ -0,0 +1,5 @@
[Unit]
BindsTo=autostart.target
[Service]
ExecStart=/usr/bin/yubikey-touch-detector -libnotify

View File

@@ -11,12 +11,12 @@ log() {
case "$1" in
enable)
log "Enabling dunst"
systemctl --user --no-block kill --signal SIGUSR2 user:dunst
systemctl --user --no-block kill --signal SIGUSR2 dunst
;;
disable)
log "Disabling dunst"
systemctl --user --no-block kill --signal SIGUSR1 user:dunst
systemctl --user --no-block kill --signal SIGUSR1 dunst
;;
*)
>&2 printf 'Unknown command\n'

View File

@@ -7,8 +7,6 @@ empty_directories:
- name: .config/gtk-3.0
- name: .config/qt5ct
dotfiles:
- from: autostart/autostart.sh
to: .autostart.sh
- from: git/gitconfig
to: .gitconfig
template: true

View File

@@ -201,8 +201,8 @@ assign [class="^Google-chrome$"] $workspace7
bindsym F2 exec --no-startup-id ~/.i3/scripts/screenmenu
bindsym $mod+F1 exec --no-startup-id ~/.i3/scripts/i3exit lock
bindsym $mod+F2 exec --no-startup-id screencfg ~/.screencfg/all.yml ; exec --no-startup-id ~/.autostart/30_keyboard.sh
bindsym $mod+F3 exec --no-startup-id screencfg ~/.screencfg/laptop.yml ; exec --no-startup-id ~/.autostart/30_keyboard.sh
bindsym $mod+F2 exec --no-startup-id screencfg ~/.screencfg/all.yml ; exec systemctl --user restart keyboard.service
bindsym $mod+F3 exec --no-startup-id screencfg ~/.screencfg/laptop.yml ; exec systemctl --user restart keyboard.service
bindsym $mod+F4 exec --no-startup-id ~/.i3/scripts/i3exit suspend
bindsym $mod+Home exec --no-startup-id ~/.i3/scripts/shutdown-menu
@@ -330,17 +330,7 @@ bindsym $mod+p exec --no-startup-id kill -SIGUSR1 $(cat $RUNDIR/wallchanger.$XDG
bindsym $mod+m exec --no-startup-id $scriptdir/pa-volume mute-toggle-mic
# exec --no-startup-id autostart
###############################################################################
##############################################################################
### BARS #######################################################################
################################################################################
#

View File

@@ -25,6 +25,8 @@ order += "volume_status input"
order += spotify
order += "wifi"
order += "external_script presentation_mode"
order += "systemd redshift"
order += "systemd spotify"
order += online_status
order += "battery_level all"
order += "clock"
@@ -42,6 +44,20 @@ battery_level all {
threshold_full = 95
}
systemd redshift {
unit = "redshift.service"
user = true
format = "  "
on_click 1 = "exec $HOME/.i3/scripts/toggle-app redshift"
}
systemd spotify {
unit = "spotify.service"
user = true
format = "  "
on_click 1 = "exec $HOME/.i3/scripts/toggle-app spotify"
}
yubikey {
format = '[  YubiKey[\?if=is_gpg ][\?if=is_u2f ] ]'
}
@@ -76,6 +92,8 @@ external_script presentation_mode {
}
online_status {
icon_on = ""
icon_off = ""
format = " {icon} "
}

View File

@@ -10,14 +10,15 @@ is_on() {
switch_on() {
touch "${_status_file}"
dunstctl disable &
systemctl --user --no-block stop user:redshift
systemctl --user --no-block stop user:spotify
systemctl --user --no-block stop redshift.service
systemctl --user --no-block stop spotify.service
}
switch_off() {
rm -f "${_status_file}"
dunstctl enable &
"$_autostart" redshift spotify
systemctl --user --no-block start redshift.service
systemctl --user --no-block start spotify.service
}

17
i3/scripts/toggle-app Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
app="${1:?app missing}"
unitname="${app}.service"
running() {
systemctl --user --quiet status "${unitname}" >/dev/null
}
if running ; then
systemctl --user stop "${unitname}"
else
systemctl --user start "${unitname}"
fi
py3-cmd refresh "systemd $app"

View File

@@ -107,7 +107,8 @@ packages:
git:
fedora: ["git", "gitk"]
ubuntu: ["git", "git-extras", "gitk", "git-email"]
archlinux: ["git"]
# tk required for gitk
archlinux: ["git", "tk"]
htop:
fedora: ["htop"]
ubuntu: ["htop"]
@@ -163,7 +164,7 @@ packages:
py3status:
fedora: ["py3status", "python3-pytz", "python3-tzlocal"]
ubuntu: ["py3status", "python3-arrow", "python3-tzlocal"]
archlinux: ["py3status", "python-pytz", "python-tzlocal", "python-dbus"]
archlinux: ["py3status", "python-pytz", "python-tzlocal", "python-dbus", "python-pydbus"]
pass:
fedora: ["pass"]
ubuntu: ["pass"]

View File

@@ -127,13 +127,24 @@
shell: /bin/bash
system: true
- name: build paru on arch
- name: check if paru is already installed
shell: |
set -o errexit
if pacman -Qi paru >/dev/null 2>&1; then
exit 100
fi
exit 0
args:
executable: /bin/bash
changed_when: false
check_mode: false
failed_when: result.rc not in (0, 100)
register: result
- name: build paru on arch
shell: |
set -o errexit
mkdir -p /tmp/paru-build
cd /tmp/paru-build
@@ -144,11 +155,9 @@
makepkg
args:
executable: /bin/bash
register: result
become: true # do not build as root!
become_user: makepkg
changed_when: result.rc != 100
failed_when: result.rc not in (0, 100)
when: result.rc != 100
- name: install paru
shell: |

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env bash
set -o xtrace
xrandr --output DisplayPort-0 --mode 2560x1440 --primary --rate 144.00 --set TearFree on

View File

@@ -410,7 +410,7 @@
- block:
- name: set kubectl version
set_fact:
kubectl_version: v1.20.0
kubectl_version: v1.20.1
- name: get current stable version
uri:
@@ -447,3 +447,28 @@
tags:
- kubectl
- name: handle autostart units
block:
- name: create systemd user directory
file:
state: directory
path: ~/{{ item }}
loop:
- .config/
- .config/systemd/
- .config/systemd/user/
- name: link autostart service files
file:
state: link
force: true
follow: false
path: "/home/{{ user.name }}/.config/systemd/user/{{ item | basename }}"
src: "{{ item }}"
owner: "{{ user.name }}"
group: "{{ user_group_name }}"
with_fileglob: /var/lib/dotfiles/autostart/services/*
tags:
- autostart

View File

@@ -25,9 +25,8 @@ start_wm() {
}
autostart() {
autostart="$HOME/.autostart.sh"
log "Executing autostart file \"$autostart\""
"$autostart" >>"${LOGFILE}" 2>&1
log "Starting systemd user target \"autostart.target\""
systemctl --user start autostart.target >>"${LOGFILE}" 2>&1
}
exec >> "$LOGFILE" 2>&1

View File

@@ -55,6 +55,9 @@ umask 0022
export {{ k }}="{{ v }}"
{% endfor %}
# Make all environment variables also usable in the systemd user instancee
systemctl --user import-environment
# exec startx breaks some logind fuckery, without exec it works
if [[ -z $DISPLAY ]] ; then
if (( $XDG_VTNR == {{ user.vt }} )) ; then