From bb696a7fa6783e9d8bda8345fa4b7f5cb090e410 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Tue, 25 Feb 2025 09:08:30 +0100 Subject: Update --- .shenanigans.sh | 150 +++++++++++++++++++++++++++++++++----------------------- .togglesink.sh | 21 -------- 2 files changed, 88 insertions(+), 83 deletions(-) delete mode 100644 .togglesink.sh diff --git a/.shenanigans.sh b/.shenanigans.sh index 5730ed6..1a213a9 100755 --- a/.shenanigans.sh +++ b/.shenanigans.sh @@ -4,68 +4,71 @@ # stow rsync entr vim xxd sbcl rlwrap podman podman-compose # clang clang-tidy clang-toolsi-extra clangd clang-analyzer -# Magical environment variables. -export NIX_SHELL_PRESERVE_PROMPT=1 -export COLORTERM=truecolor -export TERM=xterm-256color -export VISUAL=vim -export EDITOR=vim - -parse_git_branch() { - git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' -} - -is_inside_nix_shell() { - nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)" - if [[ -n "$nix_shell_name" ]]; then - echo " \e[0;36m(nix-shell)\e[0m" - fi -} - -# Better prompt. -export PS1="\n[\033[38;5;166m\]\u@\h\[$(tput sgr0)\]] \033[90m\T\033[0m$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ " - -# General aliases. -alias l='ls -lh' -alias ll='ls -lha' -alias t='tree -L 2' -alias ..='cd ..' -alias grep='grep --color=always' -alias less='less -R' -alias tmux='tmux -u' -alias vi='vim' -alias server='python3 -m http.server 6969' -alias gg='lazygit' - -# Custom folder jump commands. -alias p='cd ~/Vault/projects' -alias j='cd ~/Junk/current' -alias d='cd ~/Downloads' - -# Additional path settings. -export PATH=$HOME/Applications:$PATH -export PATH=$HOME/go/bin:$PATH -export PATH=$HOME/.local/bin:$PATH -export PATH=/usr/local/go/bin:$PATH - -# Language servers. -export PATH=$HOME/.local/bin/luals/bin:$PATH - -# Other stuff. -export PATH=$HOME/Applications/riscv-gnu-toolchain/bin:$PATH -export PATH=$HOME/Applications/xtensa-lx106-elf/bin:$PATH - -# History and search. Stolen from J. -HISTCONTROL=ignoreboth -shopt -s histappend -export HISTSIZE= -export HISTFILESIZE= -export HISTFILE=~/.bash_history_infinite -PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" -bind '"\e[A": history-search-backward' -bind '"\e[B": history-search-forward' -export HSTR_CONFIG=hicolor -if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi +# Only run if the script is being sourced (bashrc). +if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then + # Magical environment variables. + export NIX_SHELL_PRESERVE_PROMPT=1 + export COLORTERM=truecolor + export TERM=xterm-256color + export VISUAL=vim + export EDITOR=vim + + parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' + } + + is_inside_nix_shell() { + nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)" + if [[ -n "$nix_shell_name" ]]; then + echo " \e[0;36m(nix-shell)\e[0m" + fi + } + + # Better prompt. + export PS1="\n[\033[38;5;166m\]\u@\h\[$(tput sgr0)\]] \033[90m\T\033[0m$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ " + + # General aliases. + alias l='ls -lh' + alias ll='ls -lha' + alias t='tree -L 2' + alias ..='cd ..' + alias grep='grep --color=always' + alias less='less -R' + alias tmux='tmux -u' + alias vi='vim' + alias server='python3 -m http.server 6969' + alias gg='lazygit' + + # Custom folder jump commands. + alias p='cd ~/Vault/projects' + alias j='cd ~/Junk/current' + alias d='cd ~/Downloads' + + # Additional path settings. + export PATH=$HOME/Applications:$PATH + export PATH=$HOME/go/bin:$PATH + export PATH=$HOME/.local/bin:$PATH + export PATH=/usr/local/go/bin:$PATH + + # Language servers. + export PATH=$HOME/.local/bin/luals/bin:$PATH + + # Other stuff. + export PATH=$HOME/Applications/riscv-gnu-toolchain/bin:$PATH + export PATH=$HOME/Applications/xtensa-lx106-elf/bin:$PATH + + # History and search. Stolen from J. + HISTCONTROL=ignoreboth + shopt -s histappend + export HISTSIZE= + export HISTFILESIZE= + export HISTFILE=~/.bash_history_infinite + PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" + bind '"\e[A": history-search-backward' + bind '"\e[B": history-search-forward' + export HSTR_CONFIG=hicolor + if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi +fi # Backup to NAS function. Much wow! backup() { @@ -105,3 +108,26 @@ backup() { cd $CWD } +# Toggles between pulseaudio sinks in round-robin. +# Gnome shortcut: ptyxis -- bash -c 'source ~/.shenanigans.sh && togglesink' +togglesink() { + sinks=($(pactl list short sinks | awk '{print $2}')) + current_sink=$(pactl get-default-sink) + current_index=-1 + + for i in "${!sinks[@]}"; do + if [[ "${sinks[$i]}" == "$current_sink" ]]; then + current_index=$i + break + fi + done + + if [[ $current_index -eq -1 ]]; then + next_index=0 + else + next_index=$(( (current_index + 1) % ${#sinks[@]} )) + fi + + pactl set-default-sink "${sinks[$next_index]}" + notify-send "Switched to sink: ${sinks[$next_index]}" +} diff --git a/.togglesink.sh b/.togglesink.sh deleted file mode 100644 index eee44c6..0000000 --- a/.togglesink.sh +++ /dev/null @@ -1,21 +0,0 @@ -#/usr/bin/env sh - -sinks=($(pactl list short sinks | awk '{print $2}')) -current_sink=$(pactl get-default-sink) -current_index=-1 - -for i in "${!sinks[@]}"; do - if [[ "${sinks[$i]}" == "$current_sink" ]]; then - current_index=$i - break - fi -done - -if [[ $current_index -eq -1 ]]; then - next_index=0 -else - next_index=$(( (current_index + 1) % ${#sinks[@]} )) -fi - -pactl set-default-sink "${sinks[$next_index]}" -notify-send "Switched to sink: ${sinks[$next_index]}" -- cgit v1.2.3