From e9ef428ece935972e0d255f4d4655cc720a33f45 Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Wed, 11 Sep 2024 15:37:46 +0200 Subject: jim --- machines/vm-aarch64.nix | 2 +- mut/bin/setbg | 2 +- mut/st/config.h | 2 +- profiles/core/configuration.nix | 9 +++ profiles/core/home.nix | 137 ++++++++++++++++++++++++++++------------ profiles/graphical/suckless.nix | 2 +- 6 files changed, 111 insertions(+), 43 deletions(-) diff --git a/machines/vm-aarch64.nix b/machines/vm-aarch64.nix index 5ba1837..ed71515 100644 --- a/machines/vm-aarch64.nix +++ b/machines/vm-aarch64.nix @@ -18,7 +18,7 @@ ''; environment.systemPackages = with pkgs; [ kubernetes-helm - azure-cli + (azure-cli.withExtensions [azure-cli.extensions.aks-preview azure-cli.extensions.account]) awscli2 (google-cloud-sdk.withExtraComponents (with google-cloud-sdk.components; [ gke-gcloud-auth-plugin diff --git a/mut/bin/setbg b/mut/bin/setbg index accfe7d..7f5977d 100755 --- a/mut/bin/setbg +++ b/mut/bin/setbg @@ -11,7 +11,7 @@ if [ $reload -eq 1 ]; then wal -R else if [ -z "$1" ]; then - sxiv -tob ~/bg | parallel wal -i + sxiv -tob ~/Wallpapers | xargs wal -i else wal -i "$1" fi diff --git a/mut/st/config.h b/mut/st/config.h index d89d07a..c390ed9 100644 --- a/mut/st/config.h +++ b/mut/st/config.h @@ -107,7 +107,7 @@ char *termname = "st-256color"; unsigned int tabspaces = 8; /* bg opacity */ -float alpha = 0.8; +float alpha = 1.0; float alphaOffset = 0.0; float alphaUnfocus; diff --git a/profiles/core/configuration.nix b/profiles/core/configuration.nix index 31a622b..1062850 100644 --- a/profiles/core/configuration.nix +++ b/profiles/core/configuration.nix @@ -44,4 +44,13 @@ nix.extraOptions = '' experimental-features = nix-command flakes configurable-impure-env ''; + + hm.xdg.configFile."gtk-2.0/gtkrc".text = '' + gtk-key-theme-name = "Emacs" + ''; + + hm.xdg.configFile."gtk-3.0/settings.ini".text = '' + [Settings] + gtk-key-theme-name = Emacs + ''; } diff --git a/profiles/core/home.nix b/profiles/core/home.nix index f52f8a6..b50e54b 100644 --- a/profiles/core/home.nix +++ b/profiles/core/home.nix @@ -173,51 +173,109 @@ --header '╱ Enter (kubectl exec) ╱ CTRL-O (open log in vim) ╱' } - login-to-cloud () { - case $1 in - aws) - export AWS_PROFILE=$(aws configure list-profiles | grep -v default | fzf) - if ! error=$(aws sts get-caller-identity 2>&1); then - case "$error" in - *'SSO session associated with this profile has expired'*) aws sso login ;; - *'Error loading SSO Token'*) aws sso login ;; - *) echo "Not sure what to do with error: $error"; echo "trying to sign in"; aws sso login ;; - esac - fi - eval "$(aws configure export-credentials --format env)" - ;; - gcp) - gcloud config configurations activate $(gcloud config configurations list --format json | jq '.[] | "\(.name) \(.properties.core.account)"' -r | fzf | awk '{print $1}') - if ! gcloud compute instances list &> /dev/null /dev/null; then - az login --tenant $(az account show | jq '.tenantId' -r) - fi - ;; - *) echo "Don't know how to switch context for: $1" ;; - esac + G () { vi +"chdir ''${1:-.}" +G +only ; } + + login_aws() { + aws configure list-profiles | + grep -E -v -e default -e '.*_.*' | + parallel --jobs 4 --quote \ + sh -c 'aws sts get-caller-identity --profile {} 1>&2 || echo {}' | + xargs -I{} 'aws sso login --profile {}' + + AWS_PROFILE="$(aws configure list-profiles | grep -v default | fzf)" + [ -z "$AWS_PROFILE" ] && + { + echo Selected empty aws profile! + exit 1 + } + export AWS_PROFILE + if ! error="$(aws sts get-caller-identity --profile "$AWS_PROFILE" 2>&1)"; then + case "$error" in + *'SSO session associated with this profile has expired'*) aws sso login ;; + *'Error loading SSO Token'*) aws sso login ;; + *) echo "Not sure what to do with error: $error"; echo "trying to sign in"; aws sso login ;; + esac + fi + eval "$(aws configure export-credentials --profile "$AWS_PROFILE" --format env)" + } + + login_gcp() { + gcloud config configurations activate "$(gcloud config configurations list --format json | jq '.[] | "\(.name) \(.properties.core.account)"' -r | fzf | awk '{print $1}')" + projects="$(gcloud projects list --format='value(name,projectId)' 2>/dev/null)" || + { + gcloud auth login + projects="$(gcloud projects list --format='value(name,projectId)')" + } + project="$(printf '%s' "$projects" | fzf | awk '{ print $2 }')" + gcloud auth application-default set-quota-project "$project" + gcloud config set project "$project" + + gcloud auth application-default print-access-token >/dev/null 2>&1 || + { + gcloud auth application-default login + } + } + + login_azure() { + missing_tenants="$( + grep -v \ + -f /dev/fd/3 /dev/fd/4 3<<-EOF 4<<-EOF + $(az account list --output json | jq -r '.[] | .tenantId') + EOF + $(az account tenant list --output json 2>/dev/null | jq -r '.[].tenantId') + EOF + )" && { + echo "Found tenants that were not logged in! Logging into all of them" + printf '%s' "$missing_tenants + " | xargs -n1 az login --allow-no-subscriptions --tenant + } + set -- $( + { + az account list --all 2>/dev/null || + { + az login --allow-no-subscriptions && az account list --all + } + } | jq '.[] | select(.name | test("N/A.*") | not) | "\(.name)\t\(.id)"' -r | fzf + ) + + sub="$2" + az account set --subscription "''${sub:?}" + if ! az resource list >/dev/null 2>&1; then + az login --allow-no-subscriptions --tenant "$(az account show | jq '.tenantId' -r)" + fi + } + + log_in () { + case $1 in + aws) login_aws ;; + gcp) login_gcp ;; + azure) login_azure ;; + all) + login_aws + login_gcp + login_azure + ;; + *) echo "Don't know how to switch context for: $1" ;; + esac } export ZLE_REMOVE_SUFFIX_CHARS=$' ,=\t\n;&|/@' export MANPAGER='nvim +Man!' export EDITOR="nvim" export TERMINAL="st" - ( command -v brew ) &>/dev/null && eval "$(/opt/homebrew/bin/brew shellenv)" - ( command -v docker ) &>/dev/null && eval "$(docker completion zsh)" - ( command -v kubectl ) &>/dev/null && eval "$(kubectl completion zsh)" - ( command -v zoxide ) &>/dev/null && eval "$(zoxide init zsh)" - ( command -v pioctl ) &>/dev/null && eval "$(_PIOCTL_COMPLETE=zsh_source pioctl)" export PATH="''${KREW_ROOT:-$HOME/.krew}/bin:$PATH" - krew info stern && eval "$(kubectl stern --completion zsh)" - # Workaround for completion here... - ( command -v aws ) &>/dev/null && source /run/current-system/sw/share/zsh/site-functions/_aws - ( command -v az ) &>/dev/null && source /run/current-system/sw/share/zsh/site-functions/_az + # Workarounds for completion here... + { + krew info stern && eval "$(kubectl stern --completion zsh)" + ( command -v brew ) && eval "$(/opt/homebrew/bin/brew shellenv)" + ( command -v docker ) && eval "$(docker completion zsh)" + ( command -v kubectl ) && eval "$(kubectl completion zsh)" + ( command -v zoxide ) && eval "$(zoxide init zsh)" + ( command -v pioctl ) && eval "$(_PIOCTL_COMPLETE=zsh_source pioctl)" + ( command -v aws ) && source /run/current-system/sw/share/zsh/site-functions/_aws + ( command -v az ) && source /run/current-system/sw/share/zsh/site-functions/_az + } &>/dev/null [[ -f ~/.cache/wal/sequences ]] && (cat ~/.cache/wal/sequences &) unset LD_PRELOAD @@ -236,16 +294,17 @@ ssh-add -l > /dev/null || ssh-add ~/.ssh/id_ed25519_sk ''; shellAliases = { + g = "git "; t = "terraform "; c = "xclip -f | xclip -sel c -f "; open = "xdg-open "; - k9s = "k9s "; k = "kubectl "; d = "docker "; ls = "ls --color=auto"; s = "${if machine.isDarwin then "darwin-rebuild" else "sudo nixos-rebuild"} switch --flake /nix-config#${config.networking.hostName}"; b = "/run/current-system/bin/switch-to-configuration boot"; - v = "vremote"; + v = "vi "; + e = "vi "; lf = "lfub"; M = "xrandr --output HDMI1 --auto --output eDP1 --off"; m = "xrandr --output eDP1 --auto --output HDMI1 --off"; diff --git a/profiles/graphical/suckless.nix b/profiles/graphical/suckless.nix index 1144b7b..47d989e 100644 --- a/profiles/graphical/suckless.nix +++ b/profiles/graphical/suckless.nix @@ -15,7 +15,7 @@ }; services.picom = { enable = true; - activeOpacity = 0.99; + activeOpacity = 1; inactiveOpacity = 0.7; opacityRules = [ "100:class_g = 'Wfica'" -- cgit v1.2.3