diff --git a/home-manager/modules/zsh/next_wallpaper.sh b/home-manager/modules/zsh/next_wallpaper.sh index d4a2540..3e524e3 100755 --- a/home-manager/modules/zsh/next_wallpaper.sh +++ b/home-manager/modules/zsh/next_wallpaper.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # /home/krosh/Documents/Github/nixos-config/home-manager/modules/zsh/next_wallpaper.sh # Pick next or random wallpaper from ~/Pictures/Wallpapers and update symlink ~/Pictures/wallpaper.png -# Then call: hyprctl hyprpaper reload ,"$WALLPAPER" +# Then call: swww img "$WALLPAPER" set -euo pipefail diff --git a/home-manager/modules/zsh/update_system_from_git.sh b/home-manager/modules/zsh/update_system_from_git.sh new file mode 100644 index 0000000..0cd23ec --- /dev/null +++ b/home-manager/modules/zsh/update_system_from_git.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +set -euo pipefail + + + +REPO_DIR="$HOME/Documents/Github/nixos-config" +cd "$REPO_DIR" || { echo "Error: cannot change directory to $REPO_DIR" >&2; exit 1; } + +echo "Fetching latest changes from git..." +if ! git fetch --all; then + echo "Error: git fetch failed" >&2 + exit 2 +fi + +LOCAL_HASH=$(git rev-parse @) +REMOTE_HASH=$(git rev-parse @{u}) + +if [ "$LOCAL_HASH" = "$REMOTE_HASH" ]; then + echo "The repository is already up to date." + exit 0 +else + echo "Updates are available. Pulling latest changes..." + if ! git pull; then + echo "Error: git pull failed" >&2; exit 3 + fi + echo "Repository updated successfully." +fi + +chmod -R u+rwX "$REPO_DIR" + +sudo ./update-nixos.sh + +./update-home-manager.sh + +echo "System update from git completed successfully." + diff --git a/home-manager/modules/zsh/zsh.nix b/home-manager/modules/zsh/zsh.nix index 1a86c80..e58ce50 100644 --- a/home-manager/modules/zsh/zsh.nix +++ b/home-manager/modules/zsh/zsh.nix @@ -9,6 +9,7 @@ (writeShellScriptBin "move_avatar" (builtins.readFile ./move_avatar.sh)) (writeShellScriptBin "next_wallpaper" (builtins.readFile ./next_wallpaper.sh)) + (writeShellScriptBin "update_git_config" (builtins.readFile ./update_system_from_git.sh)) zsh-powerlevel10k fzf fd @@ -92,6 +93,7 @@ ''; # TODO: start system with serviceps://github.com/dylanaraps/pywal/wiki/Customization cnfg = "cd nixos-config && code . && exit"; x = "select_command"; + u = "update_git_config"; mv_w = "move_wallpaper"; next_w = "next_wallpaper";