diff --git a/configs/copy/home/.local/bin/bw b/configs/copy/home/.local/bin/bw new file mode 100755 index 0000000..c5c3e5e Binary files /dev/null and b/configs/copy/home/.local/bin/bw differ diff --git a/configs/copy/home/.local/bin/gnf b/configs/copy/home/.local/bin/gnf new file mode 100755 index 0000000..19530e8 --- /dev/null +++ b/configs/copy/home/.local/bin/gnf @@ -0,0 +1,191 @@ +#!/usr/bin/env bash +# +# gnf – Friendly wrapper around 'sudo dnf' +# Version 1.2 +# Author: You +# +# Features: +# • Implicit '-y' on install/remove/reinstall/downgrade (toggle with -n/--no-confirm) +# • 'gnf update' pipeline: +# - dnf update [-y] [--refresh] +# - flatpak update (user + system) +# - optional fwupd refresh+update +# with its own flags: -r/--refresh, -f/--firmware, -n/--no-confirm, -y/--yes +# • Passes any other 'dnf' subcommand straight to sudo dnf +# • 'copr' sub-commands get auto '-y' for addrepo/removerepo/enable/disable/list + +set -euo pipefail + +PROGRAM=$(basename "$0") +VERSION="1.2" + +usage() { + cat <&2 + usage + exit 1 +fi + +cmd=$1; shift +# Treat 'upgrade' as alias for 'update' +[[ "$cmd" == "upgrade" ]] && cmd=update + +# +# 2) Dispatch on COMMAND +# +case "$cmd" in + + # --------------------------------------------------------------- + # install/remove/reinstall/downgrade (auto '-y' unless -n) + # --------------------------------------------------------------- + install|remove|reinstall|downgrade) + dnf_args=() + $auto_yes && dnf_args+=(-y) + sudo dnf "$cmd" "${dnf_args[@]}" "$@" + exit $? + ;; + + # --------------------------------------------------------------- + # update pipeline + # --------------------------------------------------------------- + update) + # 2.1) Map any long opts to short ones for getopts + mapped=() + for arg in "$@"; do + case "$arg" in + --refresh) mapped+=(-r) ;; + --firmware) mapped+=(-f) ;; + --no-confirm) mapped+=(-n) ;; + --yes) mapped+=(-y) ;; + --) mapped+=(--);; + *) mapped+=("$arg");; + esac + done + + # 2.2) Parse update-specific flags with getopts (supports grouping: -rf) + refresh=false + firmware=false + confirm=$auto_yes + OPTIND=1 + # note: the leading colon suppresses getopts’ own error msg + while getopts ":rfny" opt "${mapped[@]}"; do + case "$opt" in + r) refresh=true ;; + f) firmware=true ;; + n) confirm=false ;; + y) confirm=true ;; + \?) echo "Unknown option '-$OPTARG' for update" >&2; exit 1 ;; + esac + done + shift $((OPTIND - 1)) + + # 2.3) Run the dnf update + dnf_args=() + $confirm && dnf_args+=(-y) + $refresh && dnf_args+=(--refresh) + sudo dnf update "${dnf_args[@]}" "$@" + + # 2.4) Run flatpak updates (user then system) + flatpak update -y + sudo flatpak update + + # 2.5) Optional firmware via fwupd + if $firmware; then + sudo fwupdmgr refresh + sudo fwupdmgr update + fi + + exit $? + ;; + + # --------------------------------------------------------------- + # copr sub-commands + # --------------------------------------------------------------- + copr) + if [[ $# -lt 1 ]]; then + echo "Error: 'gnf copr' requires a subcommand." >&2 + exit 1 + fi + sub=$1; shift + case "$sub" in + addrepo|removerepo|enable|disable|list) + sudo dnf copr "$sub" -y "$@" ;; + *) + sudo dnf copr "$sub" "$@" ;; + esac + exit $? + ;; + + # --------------------------------------------------------------- + # anything else → pass straight to sudo dnf + # --------------------------------------------------------------- + *) + sudo dnf "$cmd" "$@" + exit $? + ;; +esac diff --git a/defaults/bash/aliases b/defaults/bash/aliases index 4cb9720..9fcb302 100644 --- a/defaults/bash/aliases +++ b/defaults/bash/aliases @@ -1,7 +1,6 @@ #!/bin/bash # Aliases I like -alias update="sudo dnf update -y && flatpak update -y" alias install="sudo dnf install -y" alias letscode="cd ~/Documents/Code && ranger ." alias gtext="gnome-text-editor" diff --git a/install.sh b/install.sh index b105524..f3cb2a4 100644 --- a/install.sh +++ b/install.sh @@ -9,7 +9,7 @@ gsettings set org.gnome.desktop.screensaver lock-enabled false gsettings set org.gnome.desktop.session idle-delay 0 # Needed for all installers -sudo dnf update -y +sudo dnf update -y --refresh sudo dnf install -y curl git unzip neovim kitty zoxide # Run Scripts Required for Application Installs