thelio76: script update

This commit is contained in:
Alex 2024-07-28 11:29:56 -04:00
parent 1ee1df3854
commit f8409b9529
2 changed files with 26 additions and 3 deletions

View File

@ -71,7 +71,7 @@
extraConfig = '' extraConfig = ''
polybar & polybar &
''; '';
startupPrograms = [ "kitty" ]; startupPrograms = [ ];
}; };
}; };

View File

@ -1,6 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
commitchanges="false"
while getopts 'c' OPTION; do
case "$OPTION" in
c) commitchanges="true" ;;
esac
done
# Stolen from https://stackoverflow.com/a/29436423 # Stolen from https://stackoverflow.com/a/29436423
function yes_or_no { function yes_or_no {
while true; do while true; do
@ -12,15 +20,22 @@ function yes_or_no {
done done
} }
function reset_bspwm() {
pkill -USR1 -x sxhkd
sxhkd &
bspc wm -r
}
function apply() { function apply() {
git push --force-with-lease git push --force-with-lease
rev=$(git rev-parse HEAD) rev=$(git rev-parse HEAD)
sudo nixos-rebuild switch \ sudo nixos-rebuild switch \
--flake "git+https://git.atauno.com/atau/nixos-config.git?ref=main&rev=$rev" --flake "git+https://git.atauno.com/atau/nixos-config.git?ref=main&rev=$rev"
reset_bspwm
} }
function commit_and_apply() { function commit_and_apply() {
read -p "Enter a commit message: " msg read -p "Git working directory is unclean. Commit message: " msg
git add . git add .
git commit -m "$(hostname): $msg" git commit -m "$(hostname): $msg"
apply apply
@ -30,6 +45,14 @@ if [ -z "$(git status --porcelain)" ]
then then
apply apply
else else
yes_or_no "Git working directory is unclean, would you like to commit changes?" && commit_and_apply if [ "$commitchanges" == "false" ]
then
echo "Using local flake..."
sudo nixos-rebuild switch --flake .
reset_bspwm
else
echo "Committing flake and pushing..."
commit_and_apply
fi
fi fi