From f0458e61b572a1332d70bf62f42965770e671a19 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 2 Aug 2021 00:27:54 -0600 Subject: [PATCH] Misc changes --- dotfiles/lib/bin/brightness.sh | 3 --- dotfiles/lib/bin/dbus-introspect.sh | 10 ++++----- dotfiles/lib/bin/get_sink_input_by_pid.sh | 3 +-- dotfiles/lib/bin/run_unity.sh | 2 +- dotfiles/lib/shellenv/functions.sh | 26 +++++++++++++++++++++++ dotfiles/zprofile | 2 +- dotfiles/zshenv | 2 +- dotfiles/zshrc | 25 ++++++++++++++++++++-- rcm-link.sh | 3 +-- 9 files changed, 59 insertions(+), 17 deletions(-) delete mode 100755 dotfiles/lib/bin/brightness.sh diff --git a/dotfiles/lib/bin/brightness.sh b/dotfiles/lib/bin/brightness.sh deleted file mode 100755 index fad0861b..00000000 --- a/dotfiles/lib/bin/brightness.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env zsh - -volnoti-show $(sudo macbook_brightness.py -c "$@" -p) diff --git a/dotfiles/lib/bin/dbus-introspect.sh b/dotfiles/lib/bin/dbus-introspect.sh index bba79534..04acf60e 100755 --- a/dotfiles/lib/bin/dbus-introspect.sh +++ b/dotfiles/lib/bin/dbus-introspect.sh @@ -1,8 +1,8 @@ -#!/usr/bin/env zsh +#!/usr/bin/env sh -dbus-send --session \ +dbus-send --session \ --dest=$1 \ - --type=method_call \ - --print-reply \ - $2 \ + --type=method_call \ + --print-reply \ + $2 \ org.freedesktop.DBus.Introspectable.Introspect | tail -n +2 | sed -e "s/^ *string//" diff --git a/dotfiles/lib/bin/get_sink_input_by_pid.sh b/dotfiles/lib/bin/get_sink_input_by_pid.sh index e62e63e2..39e70c4a 100755 --- a/dotfiles/lib/bin/get_sink_input_by_pid.sh +++ b/dotfiles/lib/bin/get_sink_input_by_pid.sh @@ -1,4 +1,3 @@ -#!/usr/bin/env zsh - +#!/usr/bin/env sh get_sink_input_info.hs | jq 'select(.application_process_id == "'"$thePID"'")' diff --git a/dotfiles/lib/bin/run_unity.sh b/dotfiles/lib/bin/run_unity.sh index 32b01d0a..ed8e9aaa 100755 --- a/dotfiles/lib/bin/run_unity.sh +++ b/dotfiles/lib/bin/run_unity.sh @@ -1,3 +1,3 @@ #!/usr/bin/env sh -XDG_CURRENT_DESKTOP='Unity' $@ +XDG_CURRENT_DESKTOP='Unity' "$@" diff --git a/dotfiles/lib/shellenv/functions.sh b/dotfiles/lib/shellenv/functions.sh index 69a81b98..cfe0705d 100644 --- a/dotfiles/lib/shellenv/functions.sh +++ b/dotfiles/lib/shellenv/functions.sh @@ -270,3 +270,29 @@ function all_after_char { echo ${line##*$1} done; } + +function pasink { + pacmd stat | awk -F": " '/^Default sink name: /{print $2}' +} + +function pavolume { + pacmd list-sinks | + awk '/^\s+name: /{indefault = $2 == "<'"$(pasink)"'>"} + /^\s+volume: / && indefault {print $5; exit}' | grep -Eo "[0-9]*" +} + +function paismuted { + pactl list sinks | grep "$(pasink)" -A 10 | grep Mute | grep -q yes +} + +function pashowvolume { + if paismuted; then + volnoti-show -m + else + volnoti-show "$(min $(pavolume) 100)" + fi +} + +function pashowinputbypid { + get_sink_input_info.hs | jq 'select(.application_process_id == "'"$1"'")' +} diff --git a/dotfiles/zprofile b/dotfiles/zprofile index 6cd8b53a..8b137891 100644 --- a/dotfiles/zprofile +++ b/dotfiles/zprofile @@ -1 +1 @@ -source ~/.lib/login.sh + diff --git a/dotfiles/zshenv b/dotfiles/zshenv index 391cdeb5..8b137891 100644 --- a/dotfiles/zshenv +++ b/dotfiles/zshenv @@ -1 +1 @@ -source ~/.lib/shellenv.sh + diff --git a/dotfiles/zshrc b/dotfiles/zshrc index fa4d4b97..a218e8f5 100644 --- a/dotfiles/zshrc +++ b/dotfiles/zshrc @@ -1,6 +1,27 @@ # This is necessary for tramp. [[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return -source ~/.lib/shellrc.sh -source ~/.lib/zsh.sh + test -r ~/.custom.sh && source ~/.custom.sh source_if_exists ~/.this-machine.sh + +function emacs_ansi_term_support { + echo -e "\033AnSiTu" "$LOGNAME" # $LOGNAME is more portable than using whoami. + echo -e "\033AnSiTc" "$(pwd)" + if [ $(uname) = "SunOS" ]; then + # The -f option does something else on SunOS and is not needed anyway. + hostname_options=""; + else + hostname_options="-f"; + fi + # XXX/TODO: This disables correct setting of the current directory + # when in an sshed shell when inside of emacs + # echo -e "\033AnSiTh" "$(hostname $hostname_options)" # Using the -f option can # + # cause problems on some OSes. +} + +if environment_variable_exists INSIDE_EMACS; then + if [[ $INSIDE_EMACS == *"term"* ]] + then + add-zsh-hook precmd emacs_ansi_term_support + fi +fi diff --git a/rcm-link.sh b/rcm-link.sh index 2178b0a0..350fb0db 100755 --- a/rcm-link.sh +++ b/rcm-link.sh @@ -1,5 +1,4 @@ -#!/usr/bin/env bash - +#!/usr/bin/env sh export THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export DOTFILES_DIR="$(readlink -f $THIS_DIR/dotfiles)"