diff --git a/.bash_profile b/.bash_profile index eeda34e..cfc9d04 100644 --- a/.bash_profile +++ b/.bash_profile @@ -15,7 +15,7 @@ export BROWSER="${BROWSER:-firefox}" # $HOME cleanup export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" -export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" +export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" export XCURSOR_PATH="/usr/share/icons:$XDG_DATA_HOME/icons" export GNUPGHOME="$XDG_DATA_HOME/gnupg" export GOPATH="$XDG_DATA_HOME/go" @@ -26,18 +26,14 @@ export NODE_REPL_HISTORY="$XDG_DATA_HOME/node_repl_history" export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" # Other program settings -export SVDIR="$XDG_CONFIG_HOME/service" -export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java" export XIDLEHOOK_SOCK="$XDG_STATE_HOME/xidlehook.sock" # $PATH additions export PATH="$PATH:$HOME/.local/bin" export PATH="$PATH:$HOME/.local/bin/screenlayouts" -export PATH="$PATH:$HOME/.ghcup/bin" -export PATH="$PATH:$HOME/.cabal/bin" export PATH="$PATH:$GOPATH/bin" export PATH="$PATH:$CARGO_HOME/bin" export PATH="$PATH:$XDG_DATA_HOME/npm/bin" -# Automatic graphical start on tty1 -[ "$(tty)" = "/dev/tty2" ] && ! pidof -s Xorg >/dev/null 2>&1 && exec startx >/dev/null 2>&1 +# Automatic graphical start +[ "$(tty)" = "/dev/tty2" ] && exec startx diff --git a/.bashrc b/.bashrc index 2b62dde..87db4f3 100644 --- a/.bashrc +++ b/.bashrc @@ -1,14 +1,12 @@ # shellcheck shell=sh -case "$-" in +case $- in *i*) ;; *) return ;; esac -export HISTFILE="$XDG_STATE_HOME/bash/history" - lfcd() { - cd "$(command lf -print-last-dir "$@")" || return + cd "$(command lf -print-last-dir "$@")" || return } # Default options @@ -16,18 +14,29 @@ alias cp='cp -iv' alias mv='mv -iv' alias rm='rm -vI' alias mkdir='mkdir -pv' -alias lf='lfub' alias ls='ls --color=auto -AF' cd() { - builtin cd "$@" && ls + builtin cd "$@" && ls } alias grep='grep --color=auto' -# alias wget='wget --no-hsts-file' +alias wget='wget --no-hsts' alias vim='nvim' # Utilities alias ipp='curl https://ipinfo.io/ip && echo' -alias ipl='monitors local_ip' +ipl() { + if address="$(ip route get 1 2>/dev/null)"; then + address="${address#* via * dev * src }" + address="${address% uid *}" + fi + + if [ -n "$address" ]; then + printf '%s' "$address" + else + printf 'Offline' + fi + printf '\n' +} # Shorthands alias l='ls' @@ -48,6 +57,6 @@ alias gp='git push' alias gl='git pull' if [ -d "$XDG_DATA_HOME/bash/iceline" ]; then - . "$XDG_DATA_HOME/bash/iceline/iceline.sh" - PROMPT_COMMAND='_prompt_command' + . "$XDG_DATA_HOME/bash/iceline/iceline.sh" + PROMPT_COMMAND='_prompt_command' fi diff --git a/.local/bin/bookmarks-gen b/.local/bin/bookmarks-gen deleted file mode 100755 index cfb0ab5..0000000 --- a/.local/bin/bookmarks-gen +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" -EDITOR="${EDITOR:-vim}" - -BM_DIRS="$XDG_CONFIG_HOME/bookmarks/directories" -BM_FILES="$XDG_CONFIG_HOME/bookmarks/files" -OUTPUT_FILE="$XDG_CONFIG_HOME/shell/10-bookmarks.sh" - -cleanup_file() { - while IFS= read -r line; do - [ -z "$line" ] && continue - - while IFS='#' read -r content _; do - [ -n "$content" ] && printf '%s\n' "$content" - done <"$OUTPUT_FILE" diff --git a/.local/bin/chtsh b/.local/bin/chtsh deleted file mode 100755 index 0ad9a0f..0000000 --- a/.local/bin/chtsh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -languages="go -rust" -coreutils="awk -sed" - -while IFS= read -r line; do - case "$languages" in - *$line*) - tool="language" - selected="$line" - break - ;; - esac - case "$coreutils" in - *$line*) - tool="coreutil" - selected="$line" - break - ;; - esac -done <&2 -read -r query - -if [ -n "$query" ]; then - case "$tool" in - language) url="$selected/$query" ;; - coreutil) url="$selected~$query" ;; - esac -else - url="$selected" -fi - -curl -s "https://cht.sh/$url" diff --git a/.local/bin/lfub b/.local/bin/lfub deleted file mode 100755 index 0723bc5..0000000 --- a/.local/bin/lfub +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" -UEBERZUG_TMP_DIR="${UEBERZUG_TMP_DIR:-/tmp}" - -UB_PID= -UB_SOCKET= - -cleanup() { - exec 3>&- - ueberzugpp cmd -s "$UB_SOCKET" -a exit -} - -if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then - lf "$@" -else - [ -d "$XDG_CACHE_HOME/lf" ] || mkdir -p "$XDG_CACHE_HOME/lf" - - UB_PID_FILE="$UEBERZUG_TMP_DIR/.$(uuidgen)" - ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE" - read -r UB_PID <"$UB_PID_FILE" - rm "$UB_PID_FILE" - - UB_SOCKET="$UEBERZUG_TMP_DIR/ueberzugpp-$UB_PID.socket" - export UB_PID UB_SOCKET - trap cleanup HUP INT QUIT TERM EXIT - - lf "$@" 3>&- -fi diff --git a/.local/bin/mod-battery b/.local/bin/mod-battery new file mode 100755 index 0000000..2463dd7 --- /dev/null +++ b/.local/bin/mod-battery @@ -0,0 +1,25 @@ +#!/bin/sh + +set -eu + +FULL_THRESHOLD=90 + +for battery in /sys/class/power_supply/BAT*; do + if [ ! -f "$battery/capacity" ] || [ ! -f "$battery/status" ]; then + continue + fi + + read -r capacity <"$battery/capacity" + read -r status <"$battery/status" + + if [ "$status" = "Charging" ] || ([ "$capacity" -ge "$FULL_THRESHOLD" ] && [ "$status" = "Not charging" ]); then + prefix="AC" + else + prefix="BAT" + fi + printf '%s %s%%' "$prefix" "$capacity" + + exit 0 +done + +exit 1 diff --git a/.local/bin/mod-memory b/.local/bin/mod-memory new file mode 100755 index 0000000..3dd0265 --- /dev/null +++ b/.local/bin/mod-memory @@ -0,0 +1,53 @@ +#!/bin/sh + +set -eu + +DISPLAY_DECIMAL_PLACES=2 + +MEBI=1024 +GIBI=$((MEBI * MEBI)) +TEBI=$((GIBI * MEBI)) + +display_kib_unit() { + size_kib=$1 + decimal_places=$2 + + if [ "$size_kib" -lt "$MEBI" ]; then + size=$size_kib + unit="K" + elif [ "$size_kib" -lt "$GIBI" ]; then + size=$(printf 'scale=%s; %s / %s\n' "$decimal_places" "$size_kib" "$MEBI" | bc) + unit="M" + elif [ "$size_kib" -lt "$TEBI" ]; then + size=$(printf 'scale=%s; %s / %s\n' "$decimal_places" "$size_kib" "$GIBI" | bc) + unit="G" + else + size=$(printf 'scale=%s; %s / %s\n' "$decimal_places" "$size_kib" "$TEBI" | bc) + unit="T" + fi + + printf '%.*f%s' "$decimal_places" "$size" "$unit" +} + +mem_total= +mem_free= +mem_buffers= +mem_cached= +mem_sreclaimable= +mem_shmem= + +while read -r type value _; do + case $type in + MemTotal:) mem_total=$value ;; + MemFree:) mem_free=$value ;; + Buffers:) mem_buffers=$value ;; + Cached:) mem_cached=$value ;; + SReclaimable:) mem_sreclaimable=$value ;; + Shmem:) mem_shmem=$value ;; + esac +done ${FILE_PATH##*/}." -[ -n "$COPY" ] && xclip -sel clip -t image/png "$FILE_PATH" -[ -z "$SAVE" ] && rm "$FILE_PATH" +[ "$NOTIFY" ] && notify-send "${0##*/}" "Screenshot taken" +[ "$COPY" ] && xclip -sel clip -t image/png "$FILE_PATH" +[ "$SAVE" ] || rm "$FILE_PATH" diff --git a/.local/bin/sys-volume b/.local/bin/sys-volume new file mode 100755 index 0000000..6f011eb --- /dev/null +++ b/.local/bin/sys-volume @@ -0,0 +1,18 @@ +#!/bin/sh + +set -eu + +SINK="@DEFAULT_AUDIO_SINK@" +STATUSBAR="modbot" +STATUSBAR_SIGNAL=1 + +action=$1 + +if [ "$action" = "toggle" ]; then + wpctl set-mute "$SINK" toggle +else + wpctl set-mute "$SINK" 0 + wpctl set-volume "$SINK" "$action" +fi + +pkill -RTMIN+"$STATUSBAR_SIGNAL" "$STATUSBAR" diff --git a/.local/bin/update-pipe b/.local/bin/update-pipe deleted file mode 100755 index 2bbaab3..0000000 --- a/.local/bin/update-pipe +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -pipe="$1" -update="$2" - -PIPE_FILE="/tmp/pipe-$pipe" -[ -p "$PIPE_FILE" ] || mkfifo "$PIPE_FILE" -$update >"$PIPE_FILE" diff --git a/.local/bin/volumectrl b/.local/bin/volumectrl deleted file mode 100755 index 70e2abc..0000000 --- a/.local/bin/volumectrl +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -SINK="@DEFAULT_AUDIO_SINK@" -NOTIFY_ID=9990 -NOTIFY_URGENCY="low" - -action="${1:-}" -[ -z "$action" ] && exit 1 - -if [ "$action" = "toggle" ]; then - wpctl set-mute "$SINK" "$action" || exit 1 -else - wpctl set-volume "$SINK" "$action" || exit 1 -fi - -volume="$(wpctl get-volume "$SINK")" -case "$volume" in -*\[MUTED\]*) muted=1 ;; -*) muted=0 ;; -esac -volume="${volume% \[MUTED\]}" -volume="${volume#Volume: }" -volume="${volume%.*}${volume#*.}" -volume="${volume#0}" - -if [ "$muted" -eq 1 ]; then - icon="audio-volume-muted-symbolic" - title="Volume Muted" -else - case "$volume" in - [0-9] | [1-2][0-9] | 3[0-3]) icon="audio-volume-low-symbolic" ;; - 3[4-9] | [4-5][0-9] | 6[0-6]) icon="audio-volume-medium-symbolic" ;; - 6[7-9] | [7-9][0-9] | 100) icon="audio-volume-high-symbolic" ;; - esac - title="Volume" -fi - -notify-send -r "$NOTIFY_ID" -u "$NOTIFY_URGENCY" -h int:value:"$volume" -i "$icon" "$title" -update-pipe volume 'monitors volume'