From 24de2671df388a56744bc66fc205528dec6053b5 Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Sat, 10 Apr 2021 14:44:32 -0400 Subject: [PATCH] fix scripts and services --- files/.config/gamemode.ini | 3 - .../default.target.wants/spotifyd.service | 1 - files/.config/systemd/user/mpv.service | 8 -- .../pipewire-media-session.service | 1 + files/.config/systemd/user/spotifyd.service | 15 ---- files/.config/systemd/user/swayidle.service | 6 +- files/.config/systemd/user/tmux.service | 11 --- files/.config/systemd/user/wob.service | 2 +- files/.config/zsh/custom/101-function.zsh | 2 +- files/.tmux/plugins/tpm | 2 +- files/bin/.gitkeep | 0 files/bin/looking-glass-client | 4 - files/bin/until-success | 16 ---- files/bin/virt-usb | 80 ------------------- 14 files changed, 7 insertions(+), 144 deletions(-) delete mode 100644 files/.config/gamemode.ini delete mode 120000 files/.config/systemd/user/default.target.wants/spotifyd.service delete mode 100644 files/.config/systemd/user/mpv.service create mode 120000 files/.config/systemd/user/pipewire.service.wants/pipewire-media-session.service delete mode 100644 files/.config/systemd/user/spotifyd.service delete mode 100644 files/.config/systemd/user/tmux.service create mode 100644 files/bin/.gitkeep delete mode 100755 files/bin/looking-glass-client delete mode 100755 files/bin/until-success delete mode 100755 files/bin/virt-usb diff --git a/files/.config/gamemode.ini b/files/.config/gamemode.ini deleted file mode 100644 index f569072..0000000 --- a/files/.config/gamemode.ini +++ /dev/null @@ -1,3 +0,0 @@ -[custom] -start=$HOME/bin/__on-gamemode start -end=$HOME/bin/__on-gamemode end diff --git a/files/.config/systemd/user/default.target.wants/spotifyd.service b/files/.config/systemd/user/default.target.wants/spotifyd.service deleted file mode 120000 index 324b522..0000000 --- a/files/.config/systemd/user/default.target.wants/spotifyd.service +++ /dev/null @@ -1 +0,0 @@ -/home/marchambault/.config/systemd/user/spotifyd.service \ No newline at end of file diff --git a/files/.config/systemd/user/mpv.service b/files/.config/systemd/user/mpv.service deleted file mode 100644 index ee02cc3..0000000 --- a/files/.config/systemd/user/mpv.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=mpv - a media player - -[Service] -ExecStart=/usr/bin/mpv --idle --really-quiet --no-video --input-ipc-server /tmp/mpv.sock - -[Install] -WantedBy=default.target diff --git a/files/.config/systemd/user/pipewire.service.wants/pipewire-media-session.service b/files/.config/systemd/user/pipewire.service.wants/pipewire-media-session.service new file mode 120000 index 0000000..b091abb --- /dev/null +++ b/files/.config/systemd/user/pipewire.service.wants/pipewire-media-session.service @@ -0,0 +1 @@ +/usr/lib/systemd/user/pipewire-media-session.service \ No newline at end of file diff --git a/files/.config/systemd/user/spotifyd.service b/files/.config/systemd/user/spotifyd.service deleted file mode 100644 index 5857b89..0000000 --- a/files/.config/systemd/user/spotifyd.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=A spotify playing daemon -Documentation=https://github.com/Spotifyd/spotifyd -Wants=sound.target -After=sound.target -Wants=network-online.target -After=network-online.target - -[Service] -ExecStart=/usr/bin/spotifyd --no-daemon -Restart=always -RestartSec=12 - -[Install] -WantedBy=default.target diff --git a/files/.config/systemd/user/swayidle.service b/files/.config/systemd/user/swayidle.service index ebe8a27..7767815 100644 --- a/files/.config/systemd/user/swayidle.service +++ b/files/.config/systemd/user/swayidle.service @@ -6,9 +6,9 @@ PartOf=graphical-session.target [Service] Type=simple ExecStart=/usr/bin/swayidle -w \ - timeout 600 'echo RELOADAGENT | gpg-connect-agent; swaylock -f' \ - timeout 30 'if pgrep swaylock; then swaymsg "output * dpms off"; fi' \ - resume 'if pgrep swaylock; then swaymsg "output * dpms on"; fi' \ + timeout 600 'echo RELOADAGENT | gpg-connect-agent; swaylock -f' \ + timeout 60 'swaymsg "output * dpms off"' \ + resume 'swaymsg "output * dpms on"' \ before-sleep 'echo RELOADAGENT | gpg-connect-agent; swaylock -f' [Install] diff --git a/files/.config/systemd/user/tmux.service b/files/.config/systemd/user/tmux.service deleted file mode 100644 index b537745..0000000 --- a/files/.config/systemd/user/tmux.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Start tmux in detached session - -[Service] -Type=forking -ExecStart=/usr/bin/tmux new-session -s %u -d -ExecStop=/usr/bin/tmux kill-session -t %u - -[Install] -WantedBy=multi-user.target - diff --git a/files/.config/systemd/user/wob.service b/files/.config/systemd/user/wob.service index 224d2fd..ad1f2e4 100644 --- a/files/.config/systemd/user/wob.service +++ b/files/.config/systemd/user/wob.service @@ -4,7 +4,7 @@ PartOf=graphical-session.target [Service] Type=simple -ExecStart=/bin/bash -c "exec $HOME/bin/wob" +ExecStart=%h/.local/bin/wob [Install] WantedBy=sway-session.target diff --git a/files/.config/zsh/custom/101-function.zsh b/files/.config/zsh/custom/101-function.zsh index af352b0..5657b91 100644 --- a/files/.config/zsh/custom/101-function.zsh +++ b/files/.config/zsh/custom/101-function.zsh @@ -64,7 +64,7 @@ gamemode() { done #LD_PRELOAD="/usr/\$LIB/libgamemodeauto.so" until-success looking-glass-client -p 0 -c /tmp/win10.sock app:renderer=opengl egl:vsync=yes win:fullScreen=yes -k $@ - gamemoderun until-sucess looking-glass-client + gamemoderun until-success looking-glass-client echo "Restore system" # irq diff --git a/files/.tmux/plugins/tpm b/files/.tmux/plugins/tpm index 476f6ca..42bb2bf 160000 --- a/files/.tmux/plugins/tpm +++ b/files/.tmux/plugins/tpm @@ -1 +1 @@ -Subproject commit 476f6ca69922c9e67c408ae92dff0eb0ccb8ee51 +Subproject commit 42bb2bf48bef881be504278cf5156371b542cf81 diff --git a/files/bin/.gitkeep b/files/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/files/bin/looking-glass-client b/files/bin/looking-glass-client deleted file mode 100755 index d93ff2e..0000000 --- a/files/bin/looking-glass-client +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -#unset XDG_SESSION_TYPE -#unset SDL_VIDEODRIVER -/bin/looking-glass-client $@ diff --git a/files/bin/until-success b/files/bin/until-success deleted file mode 100755 index db09a68..0000000 --- a/files/bin/until-success +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -function stop() { - echo "Stopping" - exit 0 -} - -while true; do - echo "Starting $1" - trap - SIGINT - $@ - trap stop SIGINT - echo -e "\nPress enter to restart $1..." - read -done - diff --git a/files/bin/virt-usb b/files/bin/virt-usb deleted file mode 100755 index a9f3c01..0000000 --- a/files/bin/virt-usb +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python3 -# PYTHON_ARGCOMPLETE_OK - -import argparse -import logging -import re -import subprocess -import tempfile - -def main(**kwargs): - if kwargs.get('detach'): - virsh_subcommand = 'detach-device' - virsh_action = 'detach' - else: - virsh_subcommand = 'attach-device' - virsh_action = 'attach' - - for device in kwargs.get('device_ids'): - bus, dev = device.split(':') - with tempfile.NamedTemporaryFile('w+') as f: - f.write(f""" - - - - - - - """) - f.flush() - logging.info('%s %s',virsh_action, device) - subprocess.run(['virsh', virsh_subcommand, kwargs.get('domain'), f.name, '--live'], check=False) - -def regex_arg_type(regex): - pat = re.compile(regex) - def regex_type(value): - if pat.match(value): - return value - else: - raise argparse.ArgumentTypeError('argument "%s" must match regex "%s"' % (value, regex)) - return regex_type - -def get_libvirt_domains(): - sp = subprocess.run(['virsh', 'list', '--name'], capture_output=True, encoding='utf8', check=True) - for line in sp.stdout.split('\n'): - if line: - yield line.strip() - -def get_usb_devices(): - sp = subprocess.run(['lsusb'], capture_output=True, encoding='utf8', check=True) - for line in sp.stdout.split('\n'): - if line: - yield line.split()[5] - -if __name__ == '__main__': - logging.basicConfig(format='%(message)s', level=logging.INFO) - parser = argparse.ArgumentParser() - action_group = parser.add_mutually_exclusive_group() - action_group.add_argument('--attach', - action='store_true', - help='attach the usb devices (default)') - action_group.add_argument('--detach', - action='store_true', - help='detach the usb devices') - parser.add_argument('-d', '--domain', - choices=list(get_libvirt_domains()), - default=next(get_libvirt_domains(), None), - help='the libvirt domain on which to attach/detach the usb devices (default: %(default)s)') - parser.add_argument('device_ids', - metavar='device_ids', - nargs='+', - choices=list(get_usb_devices()), - help='a list of usb vendor:product ids in hexadecimal to attach/detach to the vm') - try: - import argcomplete - argcomplete.autocomplete(parser) - except ImportError: - pass - - args = parser.parse_args() - main(**args.__dict__)