From 90084f47809b27c954946e015c7623027d4e359b Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Wed, 18 Sep 2024 00:06:56 +0530 Subject: [PATCH] chore: kde-neon -> linux, kitty themes + settings, install-script fixes --- common/.config/kglobalshortcutsrc | 2 +- common/.config/kitty/.profile | 39 ------------ common/.config/kitty/current-theme.conf | 61 +++++++++++++++++++ common/.config/kitty/pass_keys.py | 47 ++++++++++++++ common/.profile | 1 + common/.zshrc | 5 +- kde-neon/.config/gtk-2.0/gtkrc-2.0 | 11 ---- .../.config/shell/aliases_neon.sh | 33 +++++++--- scripts/install-brew-packages.sh | 2 +- scripts/install-os-packages.sh | 16 +++++ scripts/install.sh | 16 +++-- scripts/package-list-flatpak | 8 +-- scripts/package-list-os | 8 ++- scripts/test/Dockerfile | 1 - setup.sh | 5 +- 15 files changed, 175 insertions(+), 80 deletions(-) delete mode 100644 common/.config/kitty/.profile create mode 100644 common/.config/kitty/current-theme.conf create mode 100755 common/.config/kitty/pass_keys.py delete mode 100644 kde-neon/.config/gtk-2.0/gtkrc-2.0 rename {kde-neon => linux}/.config/shell/aliases_neon.sh (83%) diff --git a/common/.config/kglobalshortcutsrc b/common/.config/kglobalshortcutsrc index 61a2831..4c05f04 100644 --- a/common/.config/kglobalshortcutsrc +++ b/common/.config/kglobalshortcutsrc @@ -7,7 +7,7 @@ switch-to-activity-fe100d1b-ab30-493d-9635-bce7284a67b9=Meta+F1,none,Switch to a [KDE Keyboard Layout Switcher] Switch keyboard layout to English (India, with rupee)=none,none,Switch keyboard layout to English (India\\, with rupee) Switch to Last-Used Keyboard Layout=Meta+Alt+L,Meta+Alt+L,Switch to Last-Used Keyboard Layout -Switch to Next Keyboard Layout=,Meta+Alt+K,Switch to Next Keyboard Layout +Switch to Next Keyboard Layout=none,Meta+Alt+K,Switch to Next Keyboard Layout _k_friendly_name=Keyboard Layout Switcher [kaccess] diff --git a/common/.config/kitty/.profile b/common/.config/kitty/.profile deleted file mode 100644 index db754eb..0000000 --- a/common/.config/kitty/.profile +++ /dev/null @@ -1,39 +0,0 @@ -# set PATH so it includes user's private bin if it exists -[ ! -d "$HOME/bin" ] || PATH="$HOME/bin:$PATH" - -# set PATH so it includes user's private bin if it exists -[ ! -d "$HOME/.local/bin" ] || PATH="$HOME/.local/bin:$PATH" - -# Set the config directory enviroment variable -[ ! -z "$XDG_CONFIG_HOME" ] || export XDG_CONFIG_HOME="$HOME/.config" - -# Set the cache directory enviroment variable -[ ! -z "$XDG_CACHE_HOME" ] || export XDG_CACHE_HOME="$HOME/.cache" - -# Set the data directory enviroment variable -[ ! -z "$XDG_DATA_HOME" ] || export XDG_DATA_HOME="$HOME/.local/share" - -# Set the state directory enviroment variable -[ ! -z "$XDG_STATE_HOME" ] || export XDG_STATE_HOME="$HOME/.local/state" - -################################################################################## - -EDITOR=$(command -v nvim 2>/dev/null || command -v vim 2>/dev/null) -VISUAL=$EDITOR - -# Manually follow steps from https://steamcommunity.com/app/646570/discussions/1/3935537639868400686 -# To disable ~/.oracle_jre_usage/ from being created - -# Source aliases -[ ! -f "$XDG_CONFIG_HOME/shell/aliases" ] || source "$XDG_CONFIG_HOME/shell/aliases" -[ ! -f "$XDG_CONFIG_HOME/shell/aliases_personal" ] || source "$XDG_CONFIG_HOME/shell/aliases_personal" - -export GNUPGHOME="$XDG_CONFIG_HOME/gnupg" -export LESSHISTFILE="$XDG_STATE_HOME/shell/lesshst" -export WGET_HSTS_FILE="$XDG_STATE_HOME/shell/wget-hsts-history" # wget aliased to use this path - -# Setup Python -export PYENV_ROOT="$XDG_DATA_HOME/pyenv" -command -v pyenv >/dev/null && export PATH="$PATH:$PYENV_ROOT/bin" -command -v pyenv >/dev/null && eval "$(pyenv init -)" -export PYTHON_HISTORY="$XDG_STATE_HOME/shell/python_history" # will be picked up by Python 3.13+ diff --git a/common/.config/kitty/current-theme.conf b/common/.config/kitty/current-theme.conf new file mode 100644 index 0000000..dbd1987 --- /dev/null +++ b/common/.config/kitty/current-theme.conf @@ -0,0 +1,61 @@ +# vim:ft=kitty + +## name: GitHub Dark Dimmed +## author: GitHub +## license: MIT + +#: The basic colors + +foreground #adbac7 +background #22272e +selection_foreground #22272e +selection_background #539bf5 + + +#: Cursor colors + +cursor #539bf5 + + +#: Tab bar colors + +tab_bar_background #1c2128 +active_tab_foreground #adbac7 +active_tab_background #22272e +inactive_tab_foreground #768390 +inactive_tab_background #1c2128 + + +#: The basic 16 colors + +#: black +color0 #545d68 +color8 #636e7b + +#: red +color1 #f47067 +color9 #ff938a + +#: green +color2 #57ab5a +color10 #6bc46d + +#: yellow +color3 #c69026 +color11 #daaa3f + +#: blue +color4 #539bf5 +color12 #6cb6ff + +#: magenta +color5 #b083f0 +color13 #dcbdfb + +#: cyan +color6 #39c5cf +color14 #56d4dd + +#: white +color7 #909dab +color15 #cdd9e5 diff --git a/common/.config/kitty/pass_keys.py b/common/.config/kitty/pass_keys.py new file mode 100755 index 0000000..0beda6c --- /dev/null +++ b/common/.config/kitty/pass_keys.py @@ -0,0 +1,47 @@ +import re + +from kittens.tui.handler import result_handler +from kitty.key_encoding import KeyEvent, parse_shortcut + + +def is_window_vim(window, vim_id): + fp = window.child.foreground_processes + return any(re.search(vim_id, p['cmdline'][0] if len(p['cmdline']) else '', re.I) for p in fp) + + +def encode_key_mapping(window, key_mapping): + mods, key = parse_shortcut(key_mapping) + event = KeyEvent( + mods=mods, + key=key, + shift=bool(mods & 1), + alt=bool(mods & 2), + ctrl=bool(mods & 4), + super=bool(mods & 8), + hyper=bool(mods & 16), + meta=bool(mods & 32), + ).as_window_system_event() + + return window.encoded_key(event) + + +def main(): + pass + + +@result_handler(no_ui=True) +def handle_result(args, result, target_window_id, boss): + direction = args[1] + key_mapping = args[2] + vim_id = args[3] if len(args) > 3 else "n?vim" + + window = boss.window_id_map.get(target_window_id) + + if window is None: + return + if is_window_vim(window, vim_id): + for keymap in key_mapping.split(">"): + encoded = encode_key_mapping(window, keymap) + window.write_to_child(encoded) + else: + boss.active_tab.neighboring_window(direction) diff --git a/common/.profile b/common/.profile index 50ca9fe..dedbb62 100644 --- a/common/.profile +++ b/common/.profile @@ -69,6 +69,7 @@ export HOMEBREW_CLEANUP_MAX_AGE_DAYS=30 export GNUPGHOME="${XDG_CONFIG_HOME}/gnupg" export LESSHISTFILE="${XDG_STATE_HOME}/shell/lesshst" export WGETRC="${XDG_CONFIG_HOME}/wgetrc" +[ ! -f "$WGETRC" ] && touch "$WGETRC" # Setup Python export PYTHON_HISTORY="${XDG_STATE_HOME}/shell/python_history" # will be picked up by Python 3.13+ diff --git a/common/.zshrc b/common/.zshrc index ce0c52b..10cecfb 100644 --- a/common/.zshrc +++ b/common/.zshrc @@ -55,7 +55,7 @@ zinit light zsh-users/zsh-completions zinit light zsh-users/zsh-autosuggestions # Oh-my-zsh plugins -# zi snippet OMZP::aliases + zi snippet OMZP::aliases # zi snippet OMZP::gitfast zi snippet OMZP::aws zi snippet OMZP::azure @@ -68,7 +68,6 @@ zi snippet OMZP::git zi snippet OMZP::gitignore zi snippet OMZP::kitty zi snippet OMZP::podman -# zi snippet OMZP::rust zi snippet OMZP::sudo zi snippet OMZP::systemd zi snippet OMZP::timer @@ -78,7 +77,7 @@ zi snippet OMZP::vi-mode zi snippet https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/per-directory-history/per-directory-history.zsh zi ice as"completion" -zi snippet OMZP::fd/_fd +#zi snippet OMZP::fd/_fd # ZSH Auto-completion settings autoload -Uz compinit diff --git a/kde-neon/.config/gtk-2.0/gtkrc-2.0 b/kde-neon/.config/gtk-2.0/gtkrc-2.0 deleted file mode 100644 index 01794b5..0000000 --- a/kde-neon/.config/gtk-2.0/gtkrc-2.0 +++ /dev/null @@ -1,11 +0,0 @@ -gtk-theme-name="Breeze" -gtk-enable-animations=1 -gtk-primary-button-warps-slider=0 -gtk-toolbar-style=3 -gtk-menu-images=1 -gtk-button-images=1 -gtk-cursor-theme-size=48 -gtk-cursor-theme-name="Sweet-cursors" -gtk-icon-theme-name="McMojave-circle-dark" -gtk-font-name="Noto Sans, 10" - diff --git a/kde-neon/.config/shell/aliases_neon.sh b/linux/.config/shell/aliases_neon.sh similarity index 83% rename from kde-neon/.config/shell/aliases_neon.sh rename to linux/.config/shell/aliases_neon.sh index 6fdfe76..727daab 100644 --- a/kde-neon/.config/shell/aliases_neon.sh +++ b/linux/.config/shell/aliases_neon.sh @@ -11,13 +11,36 @@ dir_size(){ du -ah "$dir" --max-depth=1 | sort -hr } +# TODO: Make these portable across ALL Linux distros +# TODO: flatpak +# - Portable `up` that includes `flatpak` as well +# - flatpak update +# - flatpak uninstall --unused +# - flatpak --user uninstall --unused +# - flatpak repair +# - Portable `remove` that includes: +# - dnf/apt +# - brew +# - flatpak remove +# - Link flatpak installed app's config to ~/.var dir + up(){ - sudo pkcon refresh && sudo pkcon update && sudo apt dist-upgrade && sudo apt autoremove + # TODO: dnf autoremove -y + command -v pkcon > /dev/null && sudo pkcon refresh && sudo pkcon update + command -v apt-get > /dev/null && sudo apt-get update && sudo apt-get upgrade -y && sudo apt dist-upgrade && sudo apt autoremove + command -v flatpak > /dev/null && flatpak update && flatpak uninstall --unused && flatpak --user uninstall --unused && flatpak repair command -v rustup >/dev/null && rustup update command -v brew > /dev/null && brew update && brew upgrade && brew autoremove && brew cleanup command -v npm > /dev/null && npm update -g } +# Update & Upgrades +alias distup="sudo apt dist-upgrade" +alias autorem="sudo apt autoremove" +alias update="sudo apt-get update" +alias install="sudo apt-get install " +alias remove="sudo apt-get remove " + # Network alias flush-dns="sudo systemd-resolve --flush-caches" alias dnsreset="sudo systemctl restart dnscrypt-proxy" @@ -26,14 +49,6 @@ alias ips='printf "Local IP:- "; hostname -I | cut -f1 -d " "; printf "Public IP alias ipdetails='printf "Local IP:- "; hostname -I | cut -f1 -d " "; printf "Public IP Details:- \n"; geoip' alias listening_apps="sudo netstat -nutlp | grep ':' | awk '{print \$1,\$4,\$NF}' | awk -F: '{print \$1,\$(NF-1),\$NF}' | awk -v OFS=\"\t\" 'BEGIN {printf (\"%s\t%s\t\t%s \n\", \"PROTO\", \"PORT\", \"APPLICATION\")} {print \$1 , \$(NF-1) ,\" \" , \$NF}' | (read -r; printf \"%s\n\" \"\$REPLY\"; sort -k2 -n)" - -# Update & Upgrades -alias distup="sudo apt dist-upgrade" -alias autorem="sudo apt autoremove" -alias update="sudo apt-get update" -alias install="sudo apt-get install " -alias remove="sudo apt-get remove " - # For servers alias ngt="sudo nginx -t" alias ngrestart="sudo systemctl restart nginx" diff --git a/scripts/install-brew-packages.sh b/scripts/install-brew-packages.sh index 3887ff4..181e3c9 100755 --- a/scripts/install-brew-packages.sh +++ b/scripts/install-brew-packages.sh @@ -11,7 +11,7 @@ input_file_check() { install_brew() { if ! command -v brew > /dev/null 2>&1; then - yes | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + yes | NONINTERACTIVE=1 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" fi diff --git a/scripts/install-os-packages.sh b/scripts/install-os-packages.sh index 1b523b8..8b28036 100755 --- a/scripts/install-os-packages.sh +++ b/scripts/install-os-packages.sh @@ -32,10 +32,26 @@ dnf_setup() { # Enable RPM Fusion & Install media codecs sudo dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm && sudo dnf groupupdate -y core multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin sound-and-video + + # Add VS-Code repo + sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc + printf "%s\n%s\n%s\n%s\n%s\n%s\n" "[code]" "name=Visual Studio Code" "baseurl=https://packages.microsoft.com/yumrepos/vscode" "enabled=1" "gpgcheck=1" "gpgkey=https://packages.microsoft/com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null + + # Install development Tools + sudo yum groupinstall -y "Development Tools" && yum install readline readline-devel -y + + dnf check-update } apt_setup() { sudo apt-get update && sudo apt-get upgrade -y + + # Add VS-Code repo + sudo apt-get install -y wget gpg + wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg + sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg + echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null + rm -f packages.microsoft.gpg && sudo apt-get update } input_file_check() { diff --git a/scripts/install.sh b/scripts/install.sh index e1902e1..fd8ae07 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,5 +1,13 @@ #!/usr/bin/env sh +# TODO: Things that did not work +# - Shortcuts: Maximize current window with [Windows + space] didn't +# - NEOVIM: Lazy did not download automatically +# - dotfiles: could NOT link it to aliases_personal +# TODO: Ensure KDE, Jetbrains, Zed, Sublime-text, VS-Code, flatpak, kitty: have the same theme installed + +# NOTE: should download dotfiles repo to ~ and NOT to ~/Downloads - since we are going to link Downloads + kitty_term() { curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin @@ -31,8 +39,6 @@ post_install() { ln -s /home/linuxbrew/.linuxbrew/share/fonts -t ~/.local/share && fc-cache -fv fi - # TODO: Ensure KDE, Jetbrains, Zed, Sublime-text, VS-Code, flatpak have: the same theme installed - rm -rf ~/.cache } @@ -53,10 +59,10 @@ main() { pre_install ./install-os-packages.sh - ./install-brew-packages.sh - ./install-flatpak-packages.sh + # ./install-brew-packages.sh + # ./install-flatpak-packages.sh - manual_installs + # manual_installs post_install cat "$INSTALL_LOG_FILE" diff --git a/scripts/package-list-flatpak b/scripts/package-list-flatpak index a711a8c..c73d6b5 100644 --- a/scripts/package-list-flatpak +++ b/scripts/package-list-flatpak @@ -1,17 +1,15 @@ # Lines that start with # are ignored # TIP: Only add GUI apps that aren't available/updated on OS repos com.brave.Browser -com.visualstudio.code org.mozilla.firefox -org.libreoffice.libreoffice +org.libreoffice.LibreOffice com.mattermost.Desktop md.obsidian.Obsidian com.getpostman.Postman -#com.jetbrains.Rider #com.slack.Slack com.github.tchx84.Flatseal -org.kde.KStyle.Kvantum/x86_64/6.6 org.kde.okular com.skype.Client -dev.zed.zed +dev.zed.Zed io.github.zen_browser.zen +#org.kde.KStyle.Kvantum diff --git a/scripts/package-list-os b/scripts/package-list-os index bef694d..5d7194e 100644 --- a/scripts/package-list-os +++ b/scripts/package-list-os @@ -1,6 +1,8 @@ # Lines that start with # are ignored # Below few are apt-only packages - non-free sources must be added before this apt-transport-https +build-essential +libreadline-dev libavcodec-extra nvidia-driver synaptic @@ -11,9 +13,9 @@ xorg-x11-drv-nvidia-cuda # Common bash bleachbit -build-essential ca-certificates clang +code curl evolution-ews dolphin @@ -22,6 +24,7 @@ aspnetcore-runtime-8.0 dotnet-sdk-8.0 dotnet-runtime-8.0 ffmpeg +firefox flameshot flatpak plasma-discover-backend-flatpak @@ -36,8 +39,11 @@ kde-spectacle kdeconnect kitty-terminfo llvm +lua +lua5.3 make nala +neovim net-tools openssh-client python3 diff --git a/scripts/test/Dockerfile b/scripts/test/Dockerfile index 818a3fa..74636d1 100644 --- a/scripts/test/Dockerfile +++ b/scripts/test/Dockerfile @@ -5,7 +5,6 @@ FROM debian:11-slim #FROM ubuntu:22.04 #FROM ubuntu:23.04 #FROM fedora:40 -#TODO: Arch WORKDIR /dotfiles RUN apt-get update && apt-get install sudo -y # for debian distros #RUN dnf install sudo -y # for fedora and its derivatives diff --git a/setup.sh b/setup.sh index 063574c..4b8e042 100755 --- a/setup.sh +++ b/setup.sh @@ -60,10 +60,7 @@ parse_input() { setup_symlinks() { case $(uname -a) in Linux*) - # TODO: Make it less KDE-Neon specific and more general Linux - OS="kde-neon" - - [ "$XDG_CURRENT_DESKTOP" = "KDE" ] && OS="kde-neon" + OS="linux" ;; Darwin*) OS="macos"