From 7322fc9d8406d263411efc79dd569f8ac40aa16e Mon Sep 17 00:00:00 2001 From: exu Date: Sat, 18 Nov 2023 13:20:06 +0100 Subject: [PATCH] Reload sway if active --- arch-config/scripts/arch-config.sh | 1118 ++++++++++++++-------------- 1 file changed, 561 insertions(+), 557 deletions(-) diff --git a/arch-config/scripts/arch-config.sh b/arch-config/scripts/arch-config.sh index 7a707bda..d2cf0b5e 100755 --- a/arch-config/scripts/arch-config.sh +++ b/arch-config/scripts/arch-config.sh @@ -1,557 +1,561 @@ -#!/usr/bin/env bash -set -euo pipefail - -# function to keep sudo from timing out -function func_dont_timeout { - while true; do - sudo -v - sleep 60 - done -} - -# check if user is root -if [ "$EUID" -ne 0 ]; then - sudo -v -fi - -# keep sudo active in background -func_dont_timeout & - -cat <&1 >/dev/tty) - clear - for choice in $choices; do - case $choice in - 1) - echo "nyarch" >"$HOME/.seltheme" - ;; - 2) - echo "space-pink" >"$HOME/.seltheme" - ;; - esac - done -} - -echo -cat </dev/null - -# check if the install scripts are the same -# NOTE Arguments get passed automatically now -if ! cmp --silent "$scriptloc" "$HOME/configs/arch-config/scripts/arch-config.sh"; then - echo Removed old config file and launched new one. - rm "$scriptloc" && cp "$HOME/configs/arch-config/scripts/arch-config.sh" "$HOME/scripts/" && bash ~/scripts/arch-config.sh "$@" -fi - -# if no seltheme file exists, ask to select a theme -if [[ ! -f "$HOME/.seltheme" ]]; then - func_seltheme -fi - -#################### -#### Arguments #### -#################### - -copy_firefox=0 - -# handle arguments -if [[ "$#" -eq 1 ]]; then - # -t/--theme to change theme - if [[ "$1" == "-t" || "$1" == "--theme" ]]; then - func_seltheme - elif [[ "$1" == "-f" || "$1" == "--firefox" ]]; then - copy_firefox=1 - elif [[ "$1" == "-h" || "$1" == "--help" ]]; then - echo "-h, --help Show help menu" - echo "-t, --theme Show theme selection screen" - echo "-f, --firefox Update firefox config" - exit 0 - fi -elif [[ "$#" -gt 1 ]]; then - echo "Too many arguments" - exit 1 -fi - -echo -cat </tmp/i3config.ini - cp /tmp/i3config.ini ~/.config/polybar/i3config.ini - # xresources dpi - xftdpi="$(cat ~/configs/arch-config/per-device/lupusregina/xresources-dpi-override)" - awk -v xftdpi="$xftdpi" '/!per-device dpi insert/{print;print xftdpi;next}1' ~/.Xresources >/tmp/.Xresources - cp /tmp/.Xresources ~/.Xresources - sudo cp ~/configs/arch-config/per-device/lupusregina/10-monitor.conf /etc/X11/xorg.conf.d/ - sudo cp ~/configs/arch-config/per-device/lupusregina/20-amdgpu.conf /etc/X11/xorg.conf.d/ -fi - -echo -cat <>"$HOME/.config/sway/config" - cp -r "$HOME/configs/arch-themes/nyarch/polybar" "$HOME/.config/" - #cp -r "./themes/nyarch/neofetch/lowpoly_flamegirl_blue.txt" "$HOME/.config/neofetch/lowpoly_flamegirl.txt" - #cp "./themes/.fehbg-nyarch" "$HOME/.fehbg" - #sed -i 's/^NAME=".*"/NAME="Rawrch Linyux"/' /etc/os-release -elif [[ "$seltheme" == "space-pink" ]]; then - #cp -r "./themes/space-pink/i3" "$HOME/.config/" - cat "$HOME/configs/arch-themes/space-pink/i3/color" >>"$HOME/.config/sway/config" - cp -r "$HOME/configs/arch-themes/space-pink/polybar" "$HOME/.config/" - #cp -r "./themes/space-pink/neofetch/lowpoly_flamegirl_orange.txt" "$HOME/.config/neofetch/lowpoly_flamegirl.txt" - #cp "./themes/.fehbg-space-pink" "$HOME/.fehbg" -fi - -# make fehbg executable -if [[ -f "$HOME/.fehbg" ]]; then - chmod +x ~/.fehbg -fi - -echo -cat </dev/null -cp ./bash-cat-with-cat/cat.sh "$HOME/scripts/pieces/cat.sh" -rm -rf ./bash-cat-with-cat - -: ' -echo -cat </dev/null -cp ./PSipcalc/PSipcalc.ps1 "$HOME/scripts/in_path/sc-psipcalc" -rm -rf ./PSipcalc -' -echo -cat </dev/null -fi - -# set group for libvirt -if [[ $(pacman -Q | grep libvirt) ]]; then - echo "Setting group for libvirt" - sudo gpasswd -a "$USER" libvirt 1>/dev/null -fi - -# set group for wireshark (only if installed) -if [[ $(pacman -Q | grep wireshark-qt) ]]; then - echo "Setting up group for wireshark" - sudo groupadd -f wireshark - sudo gpasswd -a "$USER" wireshark 1>/dev/null -fi - -# add group for corectrl -if [[ $(pacman -Q | grep corectrl) ]]; then - echo "Setting up group for corectrl" - sudo groupadd -f corectrl - sudo gpasswd -a "$USER" corectrl 1>/dev/null -fi - -# group for controlling backlight -echo "Setting group for backlight" -sudo groupadd -f video -sudo gpasswd -a "$USER" video 1>/dev/null - -# group for monitoring wireguard -echo "Setting group for wireguard" -sudo groupadd -f wireguard -sudo gpasswd -a "$USER" wireguard 1>/dev/null - -echo -cat </dev/null; then -# i3-msg restart 1>/dev/null -#fi - -# wait for all background jobs to finish -wait $pids && echo "Finished background jobs" - -echo -cat <&1 >/dev/tty) + clear + for choice in $choices; do + case $choice in + 1) + echo "nyarch" >"$HOME/.seltheme" + ;; + 2) + echo "space-pink" >"$HOME/.seltheme" + ;; + esac + done +} + +echo +cat </dev/null + +# check if the install scripts are the same +# NOTE Arguments get passed automatically now +if ! cmp --silent "$scriptloc" "$HOME/configs/arch-config/scripts/arch-config.sh"; then + echo Removed old config file and launched new one. + rm "$scriptloc" && cp "$HOME/configs/arch-config/scripts/arch-config.sh" "$HOME/scripts/" && bash ~/scripts/arch-config.sh "$@" +fi + +# if no seltheme file exists, ask to select a theme +if [[ ! -f "$HOME/.seltheme" ]]; then + func_seltheme +fi + +#################### +#### Arguments #### +#################### + +copy_firefox=0 + +# handle arguments +if [[ "$#" -eq 1 ]]; then + # -t/--theme to change theme + if [[ "$1" == "-t" || "$1" == "--theme" ]]; then + func_seltheme + elif [[ "$1" == "-f" || "$1" == "--firefox" ]]; then + copy_firefox=1 + elif [[ "$1" == "-h" || "$1" == "--help" ]]; then + echo "-h, --help Show help menu" + echo "-t, --theme Show theme selection screen" + echo "-f, --firefox Update firefox config" + exit 0 + fi +elif [[ "$#" -gt 1 ]]; then + echo "Too many arguments" + exit 1 +fi + +echo +cat </tmp/i3config.ini + cp /tmp/i3config.ini ~/.config/polybar/i3config.ini + # xresources dpi + xftdpi="$(cat ~/configs/arch-config/per-device/lupusregina/xresources-dpi-override)" + awk -v xftdpi="$xftdpi" '/!per-device dpi insert/{print;print xftdpi;next}1' ~/.Xresources >/tmp/.Xresources + cp /tmp/.Xresources ~/.Xresources + sudo cp ~/configs/arch-config/per-device/lupusregina/10-monitor.conf /etc/X11/xorg.conf.d/ + sudo cp ~/configs/arch-config/per-device/lupusregina/20-amdgpu.conf /etc/X11/xorg.conf.d/ +fi + +echo +cat <>"$HOME/.config/sway/config" + cp -r "$HOME/configs/arch-themes/nyarch/polybar" "$HOME/.config/" + #cp -r "./themes/nyarch/neofetch/lowpoly_flamegirl_blue.txt" "$HOME/.config/neofetch/lowpoly_flamegirl.txt" + #cp "./themes/.fehbg-nyarch" "$HOME/.fehbg" + #sed -i 's/^NAME=".*"/NAME="Rawrch Linyux"/' /etc/os-release +elif [[ "$seltheme" == "space-pink" ]]; then + #cp -r "./themes/space-pink/i3" "$HOME/.config/" + cat "$HOME/configs/arch-themes/space-pink/i3/color" >>"$HOME/.config/sway/config" + cp -r "$HOME/configs/arch-themes/space-pink/polybar" "$HOME/.config/" + #cp -r "./themes/space-pink/neofetch/lowpoly_flamegirl_orange.txt" "$HOME/.config/neofetch/lowpoly_flamegirl.txt" + #cp "./themes/.fehbg-space-pink" "$HOME/.fehbg" +fi + +# make fehbg executable +if [[ -f "$HOME/.fehbg" ]]; then + chmod +x ~/.fehbg +fi + +echo +cat </dev/null +cp ./bash-cat-with-cat/cat.sh "$HOME/scripts/pieces/cat.sh" +rm -rf ./bash-cat-with-cat + +: ' +echo +cat </dev/null +cp ./PSipcalc/PSipcalc.ps1 "$HOME/scripts/in_path/sc-psipcalc" +rm -rf ./PSipcalc +' +echo +cat </dev/null +fi + +# set group for libvirt +if [[ $(pacman -Q | grep libvirt) ]]; then + echo "Setting group for libvirt" + sudo gpasswd -a "$USER" libvirt 1>/dev/null +fi + +# set group for wireshark (only if installed) +if [[ $(pacman -Q | grep wireshark-qt) ]]; then + echo "Setting up group for wireshark" + sudo groupadd -f wireshark + sudo gpasswd -a "$USER" wireshark 1>/dev/null +fi + +# add group for corectrl +if [[ $(pacman -Q | grep corectrl) ]]; then + echo "Setting up group for corectrl" + sudo groupadd -f corectrl + sudo gpasswd -a "$USER" corectrl 1>/dev/null +fi + +# group for controlling backlight +echo "Setting group for backlight" +sudo groupadd -f video +sudo gpasswd -a "$USER" video 1>/dev/null + +# group for monitoring wireguard +echo "Setting group for wireguard" +sudo groupadd -f wireguard +sudo gpasswd -a "$USER" wireguard 1>/dev/null + +echo +cat </dev/null; then +# i3-msg restart 1>/dev/null +#fi + +if [ $XDG_SESSION_DESKTOP == "sway" ]; then + swaymsg reload +fi + +# wait for all background jobs to finish +wait $pids && echo "Finished background jobs" + +echo +cat <