diff --git a/.gitignore b/.gitignore index 4a3471b..fe45d3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ +# Ignore Wireguard config of course! /config/wg/** +# Ignore bash environment variables. /config/bash/env +# Ignore backups of old config files +/config/old/** diff --git a/bin/get-port b/bin/get-port new file mode 100755 index 0000000..ff024c3 --- /dev/null +++ b/bin/get-port @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 + +import subprocess +import questionary +import re +import sys + +def get_interfaces(): + try: + # Run tcpdump -D command + result = subprocess.run(['sudo', 'tcpdump', '-D'], + capture_output=True, + text=True) + + # Split output into lines and create a list of interfaces + interfaces = [] + for line in result.stdout.split('\n'): + if line.strip(): + # Extract interface name and description + match = re.match(r'\d+\.(.+)', line) + if match: + interfaces.append(line) + + return interfaces + except Exception as e: + print(f"Error getting interfaces: {e}") + sys.exit(1) + +def get_port_info(interface_number): + try: + # Extract just the number from the interface selection + number = interface_number.split('.')[0] + + # Run tcpdump command for port info + cmd = [ + 'sudo', 'tcpdump', '-nnv', + '-i', number, + '-s', '1500', + '-c', '1', + 'ether[12:2]==0x88cc' + ] + + print("\nListening for LLDP packets (this might take a few seconds)...") + result = subprocess.run(cmd, capture_output=True, text=True) + + return result.stdout or result.stderr + except Exception as e: + print(f"Error getting port info: {e}") + sys.exit(1) + +def main(): + # Get list of interfaces + interfaces = get_interfaces() + + if not interfaces: + print("No interfaces found!") + sys.exit(1) + + # Let user select an interface + selected = questionary.select( + "Select an interface to check port information:", + choices=interfaces + ).ask() + + if selected: + # Get and display port information + port_info = get_port_info(selected) + print("\nPort Information:") + print(port_info) + else: + print("No interface selected.") + +if __name__ == "__main__": + main() diff --git a/bin/gnf b/bin/gnf new file mode 100755 index 0000000..19530e8 --- /dev/null +++ b/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/config/bash/.bashrc.bak b/config/bash/.bashrc.bak deleted file mode 100644 index 1ed1d53..0000000 --- a/config/bash/.bashrc.bak +++ /dev/null @@ -1,25 +0,0 @@ -# .bashrc - -# Source global definitions -if [ -f /etc/bashrc ]; then - . /etc/bashrc -fi - -# User specific environment -if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then - PATH="$HOME/.local/bin:$HOME/bin:$PATH" -fi -export PATH - -# Uncomment the following line if you don't like systemctl's auto-paging feature: -# export SYSTEMD_PAGER= - -# User specific aliases and functions -if [ -d ~/.bashrc.d ]; then - for rc in ~/.bashrc.d/*; do - if [ -f "$rc" ]; then - . "$rc" - fi - done -fi -unset rc diff --git a/config/dot/nvim/lazy-lock.json b/config/dot/nvim/lazy-lock.json index 206a99a..bc78c3d 100644 --- a/config/dot/nvim/lazy-lock.json +++ b/config/dot/nvim/lazy-lock.json @@ -1,6 +1,6 @@ { "LuaSnip": { "branch": "master", "commit": "5a1e39223db9a0498024a77b8441169d260c8c25" }, - "avante.nvim": { "branch": "main", "commit": "7f48770e66684e9a7d4d5b9c47505a23e0167a6e" }, + "avante.nvim": { "branch": "main", "commit": "f8a7cd1a606460ec0a2c4ec886bc102daccf912e" }, "barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" }, "cloak.nvim": { "branch": "main", "commit": "648aca6d33ec011dc3166e7af3b38820d01a71e4" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, @@ -19,7 +19,7 @@ "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, "cmp-tw2css": { "branch": "main", "commit": "1abe0eebcb57fcbd5538d054f0db61f4e4a1302b" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "26c02e1155a4980900bdccabca4516f4c712aae9" }, + "conform.nvim": { "branch": "master", "commit": "cde4da5c1083d3527776fee69536107d98dae6c9" }, "copilot.vim": { "branch": "release", "commit": "da369d90cfd6c396b1d0ec259836a1c7222fb2ea" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "fidget.nvim": { "branch": "main", "commit": "e32b672d8fd343f9d6a76944fedb8c61d7d8111a" }, @@ -27,32 +27,32 @@ "gitsigns.nvim": { "branch": "main", "commit": "20ad4419564d6e22b189f6738116b38871082332" }, "image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" }, "img-clip.nvim": { "branch": "main", "commit": "e7e29f0d07110405adecd576b602306a7edd507a" }, - "lazy.nvim": { "branch": "main", "commit": "e6a8824858757ca9cd4f5ae1a72d845fa5c46a39" }, + "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, "lspkind.nvim": { "branch": "master", "commit": "3ddd1b4edefa425fda5a9f95a4f25578727c0bb3" }, "lualine.nvim": { "branch": "master", "commit": "3946f0122255bc377d14a59b27b609fb3ab25768" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "d7b5feb6e769e995f7fcf44d92f49f811c51d10c" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "b1d9a914b02ba5660f1e272a03314b31d4576fe2" }, "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, "mcphub.nvim": { "branch": "main", "commit": "8ff40b5edc649959bb7e89d25ae18e055554859a" }, "mini.icons": { "branch": "main", "commit": "ff2e4f1d29f659cc2bad0f9256f2f6195c6b2428" }, - "neo-tree.nvim": { "branch": "v3.x", "commit": "8cdd6b1940f333c1dd085526a9c45b30fb2dbf50" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" }, "nerdcommenter": { "branch": "master", "commit": "02a3b6455fa07b61b9440a78732f1e9b7876c991" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" }, "nvim-cmp": { "branch": "main", "commit": "106c4bcc053a5da783bf4a9d907b6f22485c2ea0" }, "nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" }, - "nvim-lspconfig": { "branch": "master", "commit": "2010fc6ec03e2da552b4886fceb2f7bc0fc2e9c0" }, + "nvim-lspconfig": { "branch": "master", "commit": "c8503e63c6afab3ed34b49865a4a4edbb1ebf4a8" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-treesitter-context": { "branch": "master", "commit": "ec308c7827b5f8cb2dd0ad303a059c945dd21969" }, + "nvim-treesitter-context": { "branch": "master", "commit": "660861b1849256398f70450afdf93908d28dc945" }, "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, "nvim-web-devicons": { "branch": "master", "commit": "8dcb311b0c92d460fac00eac706abd43d94d68af" }, "nvim-window-picker": { "branch": "main", "commit": "6382540b2ae5de6c793d4aa2e3fe6dbb518505ec" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "render-markdown.nvim": { "branch": "main", "commit": "a1b2bf029c37397947082f31969b4aec0d1b92bd" }, - "snacks.nvim": { "branch": "main", "commit": "41712e3026a6d690e3c65f83b335cb34e054d2cd" }, + "render-markdown.nvim": { "branch": "main", "commit": "f58c05f349d6e7650f4b40b0df1514400f0c10de" }, + "snacks.nvim": { "branch": "main", "commit": "dec29f55666f8f4545835636077a86b150faf630" }, "supermaven-nvim": { "branch": "main", "commit": "07d20fce48a5629686aefb0a7cd4b25e33947d50" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "tokyonight.nvim": { "branch": "main", "commit": "b13cfc1286d2aa8bda6ce137b79e857d5a3d5739" }, + "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, "undotree": { "branch": "master", "commit": "0f1c9816975b5d7f87d5003a19c53c6fd2ff6f7f" } } diff --git a/install b/install index 549aae7..1066b1b 100755 --- a/install +++ b/install @@ -6,8 +6,4 @@ source ~/.local/share/Panama/bin/ascii read -p "What should the hostname be? " HOST_NAME sudo hostnamectl set-hostname $HOST_NAME -# Ensure computer doesn't go to sleep while installing -gsettings set org.gnome.desktop.screensaver lock-enabled false -gsettings set org.gnome.desktop.session idle-delay 0 - for script in ~/.local/share/Panama/setup/scripts/*; do source $script; done diff --git a/setup/packages/development-packages b/setup/packages/development-packages index 29e330f..559de24 100644 --- a/setup/packages/development-packages +++ b/setup/packages/development-packages @@ -1,7 +1,6 @@ bison clang-analyzer clangd -cliphist cmake compat-lua composer diff --git a/setup/scripts/install-initial-packages b/setup/scripts/install-packages similarity index 58% rename from setup/scripts/install-initial-packages rename to setup/scripts/install-packages index cd96756..224ff67 100755 --- a/setup/scripts/install-initial-packages +++ b/setup/scripts/install-packages @@ -4,15 +4,18 @@ log() { echo -e "\033[1;34m[INFO]\033[0m $*"; } exists() { command -v "$1" >/dev/null 2>&1; } -echo -e "\n--- Installing initial packages ---\n" +# --- Defined Paths --- +PANAMA_PATH="$HOME/.local/share/Panama" + +echo -e "\n--- Installing relevant packages ---\n" # --- Install all initial packages --- -PACKAGES_FILE="$HOME/.local/share/Panama/setup/packages/initial-packages" +PACKAGES_FILE="$PANAMA_PATH/setup/packages/initial-packages" if [[ -f "$PACKAGES_FILE" ]]; then INITIAL_PACKAGES=$(tr "\n" " " <"$PACKAGES_FILE") log "Installing $INITIAL_PACKAGES" sudo dnf install -y "$INITIAL_PACKAGES" > /dev/null 2>&1 - log "Packages installed!" + log "Initial packages installed!" else log "Package list was not in specified path: $PACKAGES_FILE" fi @@ -40,3 +43,23 @@ else log "Installing oh-my-posh via curl..." curl -s https://ohmyposh.dev/install.sh | bash -s -- -d "$LOCAL_BIN_PATH" > /dev/null 2>&1 fi + +# --- Install Development Packages needed for Neovim --- +DEV_FILE="$PANAMA_PATH/setup/packages/development-packages" +if [[ -f "$DEV_FILE" ]]; then + DEV_PACKAGES=$(tr "\n" " " <"$DEV_FILE") + log "Installing $DEV_PACKAGES" + #sudo dnf install -y $DEV_PACKAGES > /dev/null 2>&1 + sudo dnf install -y $DEV_PACKAGES + log "Development packages installed!" +else + log "Package list was not in specified path: $DEV_FILE" +fi + +# --- Install Bun --- +if [[ -x "$HOME/.bun/bin/bun" ]]; then + log "Bun already installed at \"$HOME/.bun/bin/bun\"" +else + log "Installing Bun via curl..." + curl -fsSL https://bun.sh/install | bash > /dev/null 2>&1 +fi diff --git a/setup/scripts/link-dotfiles b/setup/scripts/link-dotfiles index 7683a98..5181fac 100755 --- a/setup/scripts/link-dotfiles +++ b/setup/scripts/link-dotfiles @@ -3,15 +3,33 @@ # Define paths as they have not been defined by new bashrc yet! PANAMA_PATH="${PANAMA_PATH:-$HOME/.local/share/Panama}" PANAMA_BASH="${PANAMA_BASH:-$PANAMA_PATH/config/bash}" +PANAMA_DOT="$PANAMA_PATH/config/dot" +PANAMA_OLD="$PANAMA_PATH/config/old" +CONFIG="$HOME/.config" +# Make backup folder if it doesn't exist +mkdir -p "$PANAMA_OLD" + +# --- Bashrc --- # Backup existing .bashrc if it's a regular file if [ -f "$HOME/.bashrc" ] && [ ! -L "$HOME/.bashrc" ]; then - mv "$HOME/.bashrc" "$PANAMA_BASH/.bashrc.bak" + mv "$HOME/.bashrc" "$PANAMA_OLD/.bashrc" fi - # Remove old symlink if it exists and points somewhere else if [ -L "$HOME/.bashrc" ]; then rm "$HOME/.bashrc" fi - +# Symlink Panama .bashrc file to ~/.bashrc ln -s "$PANAMA_BASH/.bashrc" "$HOME/.bashrc" + +# --- Neovim --- +# Backup existing Neovim config if it's a regular directory +if [ -d "$CONFIG/nvim" ] && [ ! -L "$CONFIG/nvim"]; then + mv "$CONFIG/nvim" "$PANAMA_OLD/nvim" +fi +# Remove old symlink if it exists & points to somewhere else +if [ -L "$CONFIG/nvim" ]; then + rm "$CONFIG/nvim" +fi +# Symlink Panama nvim directory to ~/.config/nvim +ln -s "$PANAMA_DOT/nvim" "$CONFIG/nvim"