diff options
| author | Peter Son Struschka <me@peter-struschka.com> | 2020-07-29 16:40:02 +0800 |
|---|---|---|
| committer | Peter Son Struschka <me@peter-struschka.com> | 2020-07-29 16:48:22 +0800 |
| commit | a1d6fc2f3e6ab041cc51cb085ac59a646a126d25 (patch) | |
| tree | b1ca8b11365cd255dd2f93a47dd0e918e1dae16a /basics | |
| parent | 556bbd7fd182937e32eb5320a27ba337ac454be0 (diff) | |
| download | dotfiles-a1d6fc2f3e6ab041cc51cb085ac59a646a126d25.tar.gz dotfiles-a1d6fc2f3e6ab041cc51cb085ac59a646a126d25.tar.bz2 dotfiles-a1d6fc2f3e6ab041cc51cb085ac59a646a126d25.tar.lz dotfiles-a1d6fc2f3e6ab041cc51cb085ac59a646a126d25.tar.xz dotfiles-a1d6fc2f3e6ab041cc51cb085ac59a646a126d25.tar.zst dotfiles-a1d6fc2f3e6ab041cc51cb085ac59a646a126d25.zip | |
basics+bspwm+herbstluftwm+i3wm+meta+polybar+xmonad: wm configs overhaul
Created polybar as its own config instead of duplicated in bspwm and
i3's directories allowing them both to be installed.
Created herbstluftwm, xmonad window manager configs.
Added scripts for a status bar, and fixed scripts.
Diffstat (limited to 'basics')
| -rw-r--r-- | basics/.config/alacritty/alacritty.yml | 71 | ||||
| -rw-r--r-- | basics/.config/newsboat/urls | 1 | ||||
| -rw-r--r-- | basics/.config/npm/npmrc | 1 | ||||
| -rwxr-xr-x | basics/.local/bin/battery-monitor | 45 | ||||
| -rwxr-xr-x | basics/.local/bin/change-vol | 10 | ||||
| -rwxr-xr-x | basics/.local/bin/edit-config | 4 | ||||
| -rwxr-xr-x | basics/.local/bin/locate-config | 30 | ||||
| -rwxr-xr-x | basics/.local/bin/macho | 25 | ||||
| -rwxr-xr-x | basics/.local/bin/statusbar/battery | 30 | ||||
| -rwxr-xr-x | basics/.local/bin/statusbar/memory | 22 |
10 files changed, 198 insertions, 41 deletions
diff --git a/basics/.config/alacritty/alacritty.yml b/basics/.config/alacritty/alacritty.yml index d49d07d..e84f5f4 100644 --- a/basics/.config/alacritty/alacritty.yml +++ b/basics/.config/alacritty/alacritty.yml @@ -3,14 +3,14 @@ # Any items in the `env` entry below will be added as # environment variables. Some entries may override variables # set by alacritty itself. -#env: +env: # TERM variable # # This value is used to set the `$TERM` environment variable for # each instance of Alacritty. If it is not present, alacritty will # check the local terminfo database and use `alacritty` if it is # available, otherwise `xterm-256color` is used. - #TERM: xterm-256color + TERM: xterm-256color window: # Window dimensions (changes require restart) @@ -26,8 +26,8 @@ window: # Blank space added around the window in pixels. This padding is scaled # by DPI and the specified value is always added at both opposing sides. padding: - x: 2 - y: 2 + x: 0 + y: 0 # Spread additional padding evenly around the terminal content. dynamic_padding: false @@ -50,13 +50,28 @@ window: # - Fullscreen startup_mode: Maximized + # Window title + #title: Alacritty + + # Window class (Linux/BSD only): + #class: + # Application instance name + #instance: Alacritty + # General application class + #general: Alacritty + + # GTK theme variant (Linux/BSD only) + # + # Override the variant of the GTK theme. Commonly supported values are `dark` and `light`. + # Set this to `None` to use the default theme variant. + #gtk_theme_variant: None + scrolling: # Maximum number of lines in the scrollback buffer. # Specifying '0' will disable scrolling. history: 10000 - # Number of lines the viewport will move for every line scrolled when - # scrollback is enabled (history > 0). + # Scrolling distance multiplier multiplier: 3 # Font configuration (changes require restart) @@ -96,8 +111,19 @@ font: # The `style` can be specified to pick a specific face. #style: Italic + # Bold italic font face + #bold_italic: + # Font family + # + # If the bold italic family is not specified, it will fall back to the + # value specified for the normal font. + #family: monospace + + # The `style` can be specified to pick a specific face. + #style: Bold Italic + # Point size - size: 13.0 + size: 8.0 # Offset is the extra space around each character. `offset.y` can be thought of # as modifying the line spacing, and `offset.x` as modifying the letter spacing. @@ -128,14 +154,6 @@ font: # effect. use_thin_strokes: true -# Debug options -debug: - # Display the time it takes to redraw each frame. - render_timer: false - - # Keep the log file after quitting Alacritty. - persistent_logging: false - # If `true`, bold text is drawn using the bright color variants. draw_bold_text_with_bright_colors: true @@ -522,3 +540,26 @@ key_bindings: - { key: F11, mods: Super, chars: "\x1b[23;3~" } - { key: F12, mods: Super, chars: "\x1b[24;3~" } - { key: NumpadEnter, chars: "\n" } + +# Debug options +debug: + # Display the time it takes to redraw each frame. + render_timer: false + + # Keep the log file after quitting Alacritty. + persistent_logging: false + + # Log level + # + # Values for `log_level`: + # - None + # - Error + # - Warn + # - Info + # - Debug + # - Trace + #log_level: Warn + + # Print all received window events. + #print_events: false + diff --git a/basics/.config/newsboat/urls b/basics/.config/newsboat/urls index 134c73c..e07c8b6 100644 --- a/basics/.config/newsboat/urls +++ b/basics/.config/newsboat/urls @@ -1,2 +1,3 @@ https://www.archlinux.org/feeds/news/ https://www.archlinux.org/feeds/planet/ +https://news.ycombinator.com/rss diff --git a/basics/.config/npm/npmrc b/basics/.config/npm/npmrc index fc84b78..3691078 100644 --- a/basics/.config/npm/npmrc +++ b/basics/.config/npm/npmrc @@ -2,3 +2,4 @@ prefix=${XDG_DATA_HOME}/npm cache=${XDG_CACHE_HOME}/npm tmp=${XDG_RUNTIME_DIR}/npm init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js + diff --git a/basics/.local/bin/battery-monitor b/basics/.local/bin/battery-monitor index ff1ef8b..1dfa7b6 100755 --- a/basics/.local/bin/battery-monitor +++ b/basics/.local/bin/battery-monitor @@ -1,6 +1,41 @@ +#!/bin/sh + +battery_path='/sys/class/power_supply/BAT0' + +percentage=$(head -n1 "${battery_path}/capacity") +state=$(head -n1 "${battery_path}/status") +rate=$([ -f "${battery_path}/current_now" ] && head -n1 "${battery_path}/current_now" || head -n1 "${battery_path}/power_now") +volt=$(head -n1 "${battery_path}/voltage_now") +now=$([ -f "${battery_path}/charge_now" ] && head -n1 "${battery_path}/charge_now" || head -n1 "${battery_path}/energy_now") +max=$([ -f "${battery_path}/current_full" ] && head -n1 "${battery_path}/current_full" || head -n1 "${battery_path}/energy_full") +cap=$([ "$state" = "Charging" ] && printf "%d-%d\n" "${max}" "${now}" | bc || echo "${now}") + +remaining=$( printf "%d/%d\n" "${cap}" "${volt}" | bc -l ) +current_rate=$( printf "%d/%d\n" "${rate}" "${volt}" | bc -l ) +echo $( [ "${current_rate}" != "0" ] && echo "not zero" || echo "is zero" ) +seconds=$( [ "${current_rate}" != "0" ] && printf "3600*%f/%f\n" "${remaining}" "${current_rate}" | bc || echo "0") +time_remaining=$( date -ud "@${seconds}" "+%H:%M:%S" ) + +echo "percentage ${percentage}%" +echo "state ${state}" +echo "rate ${rate}" +echo "volt ${volt}" +echo "now ${now}" +echo "max ${max}" +echo "cap ${cap}" +echo "remaining ${remaining}" +echo "current_rate ${current_rate}" +echo "seconds ${seconds}" +echo "time ${time_remaining}" + +exit 0 + battery_level=`acpi -b | cut -d ' ' -f 4 | grep -o '[0-9]*'` +battery_level=$(head -n1 /sys/class/power_supply/BAT0/capacity) battery_state=$(acpi | grep 'Battery' | sed 's/Battery\s[0-9]*: //' | sed 's/, [0-9][0-9]*\%.*//') +battery_state=$(head -n1 /sys/class/power_supply/BAT0/status) battery_remaining=$(acpi | grep -oh '[0-9:]* remaining' | sed 's/:\w\w remaining$/ Minutes/' | sed 's/00://' | sed 's/:/h /') +kk if [ ! -f "/tmp/.battery" ]; then echo "$battery_level" > /tmp/.battery @@ -18,12 +53,12 @@ checkBatteryLevel() { exit fi - if [ $battery_level -le 3 ]; then + if [ $battery_level -le 4 ]; then sudo systemctl suspend - elif [ $battery_level -le 5 ]; then - notify-send "Low Battery" "Your computer will suspend soon unless plugged into a power outlet." -u critical + elif [ $battery_level -le 7 ]; then + notify-send "Low Battery" "(${time_remaining}) Your computer will suspend soon unless plugged into a power outlet." -u critical elif [ $battery_level -le 10 ]; then - notify-send "Low Battery" "${battery_level}% (${battery_remaining}) of battery remaining." -u normal + notify-send "Low Battery" "${battery_level}% (${time_remaining}) of battery remaining." -u normal fi } @@ -38,4 +73,4 @@ checkBatteryStateChange() { } checkBatteryStateChange -checkBatteryLevel
\ No newline at end of file +checkBatteryLevel diff --git a/basics/.local/bin/change-vol b/basics/.local/bin/change-vol new file mode 100755 index 0000000..a4309fd --- /dev/null +++ b/basics/.local/bin/change-vol @@ -0,0 +1,10 @@ +#!/bin/sh + +case "$1" in + "+") ;; + "-") ;; + *) exit 1; +esac + +pactl set-sink-mute 0 false +pactl set-sink-volume 0 "${1}5%" diff --git a/basics/.local/bin/edit-config b/basics/.local/bin/edit-config index 7d1baae..436a812 100755 --- a/basics/.local/bin/edit-config +++ b/basics/.local/bin/edit-config @@ -1,6 +1,6 @@ #/bin/sh FILE=$(locate-config) -[ -z "$FILE" ] && exit 1 +[ -z "$FILE" ] || [ ! -f "$FILE" ] && exit 1 -$EDITOR $FILE +${TERMINAL} -e ${EDITOR} ${FILE} diff --git a/basics/.local/bin/locate-config b/basics/.local/bin/locate-config index d798a39..26fd2cb 100755 --- a/basics/.local/bin/locate-config +++ b/basics/.local/bin/locate-config @@ -1,24 +1,16 @@ -#! /usr/bin/env bash +#!/bin/sh set -e -CONFIG_FILES=`ls -1 ~/.local/share/config-files | cut -d "" -f 1 | sort -d` -CONFIG_ARRAY=(`find ~/.local/share/config-files/ -maxdepth 1 -mindepth 1 -print0 | sort -z | xargs -r0 echo`) +config_dir="$HOME/.local/share/config-files" -INDEX=`echo "$CONFIG_FILES" | rofi -dmenu -format "i" -no-custom -mesg "Find config file for..."` -[ -z "$INDEX" ] && exit 1 -SOURCE=${CONFIG_ARRAY[$INDEX]} -#echo "$CONFIG_FILES" -#for item in ${CONFIG_ARRAY[*]} -#do -# printf " %s\n" $item -#done -# (https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself) -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" +p="Config:" + +sel=$(find "$config_dir" -writable -type l | cut -d "/" -f 7- | sort -d | dmenu -p "$p" -l 20) +ec=$? +[ "$ec" -ne 0 ] && exit $ec + +target=$(readlink -f "${config_dir}/${sel}") + +echo "$target" -echo $SOURCE diff --git a/basics/.local/bin/macho b/basics/.local/bin/macho new file mode 100755 index 0000000..2566d7d --- /dev/null +++ b/basics/.local/bin/macho @@ -0,0 +1,25 @@ +#!/bin/sh + +export FZF_DEFAULT_OPTS=' +--height=30% +--layout=reverse +--prompt="Manual: " +--preview="echo {1} | sed -E \"s/^\((.+)\)/\1/\" | xargs -I{S} man -Pcat {S} {2} 2>/dev/null"' + +while getopts ":s:" opt; do + case $opt in + s ) SECTION=$OPTARG; shift; shift;; + \?) echo "Invalid option: -$OPTARG" >&2; exit 1;; + : ) echo "Option -$OPTARG requires an argument" >&2; exit 1;; + esac +done + +manual=$(apropos -s ${SECTION:-''} ${@:-.} | \ + grep -v -E '^.+ \(0\)' |\ + awk '{print $2 " " $1}' | \ + sort | \ + fzf | \ + sed -E 's/^\((.+)\)/\1/') + +[ -z "$manual" ] && exit 0 +man $manual diff --git a/basics/.local/bin/statusbar/battery b/basics/.local/bin/statusbar/battery new file mode 100755 index 0000000..da6dd12 --- /dev/null +++ b/basics/.local/bin/statusbar/battery @@ -0,0 +1,30 @@ +#!/bin/sh + +battery_path='/sys/class/power_supply/BAT0' + +percentage=$(head -n1 "${battery_path}/capacity") +state=$(head -n1 "${battery_path}/status") +rate=$([ -f "${battery_path}/current_now" ] && + head -n1 "${battery_path}/current_now" || + head -n1 "${battery_path}/power_now") +volt=$(head -n1 "${battery_path}/voltage_now") +now=$([ -f "${battery_path}/charge_now" ] && + head -n1 "${battery_path}/charge_now" || + head -n1 "${battery_path}/energy_now") +max=$([ -f "${battery_path}/current_full" ] && + head -n1 "${battery_path}/current_full" || + head -n1 "${battery_path}/energy_full") +cap=$([ "$state" = "Charging" ] && + echo "$max $now" | awk '{printf "%d", $1 - $2}' || + echo "$now") + +remaining=$( echo "$cap $volt" | awk '{printf "%f", $1/$2}' ) +current_rate=$( echo "$rate $volt" | awk '{printf "%f", $1/$2}' ) +seconds_remaining=$( [ "${current_rate#0.00}" = "$current_rate" ] && + echo "$remaining $current_rate" | + awk '{printf "%d", 3600*$1/$2}' || + echo "0" ) +time_remaining=$( date -ud "@${seconds_remaining}" "+%H:%M:%S" ) + +# TODO: more variable output with flags? +echo "$state $percentage $time_remaining" diff --git a/basics/.local/bin/statusbar/memory b/basics/.local/bin/statusbar/memory new file mode 100755 index 0000000..7a952d8 --- /dev/null +++ b/basics/.local/bin/statusbar/memory @@ -0,0 +1,22 @@ +#!/bin/sh + +meminfo=$(awk ' +/^MemTotal:/ {Total=$2*1024} +/^MemAvailable:/ {Available=$2*1024} +/^MemFree:/ {Free=$2*1024} +/^Buffers:/ {Buffers=$2*1024} +/^Cached:/ {Cached=$2*1024} +/^SReclaimable:/ {SReclaimable=$2*1024} +/^Shmem:/ {Shmem=$2*1024} +END { +print Total ":" Available ":" Free ":" Buffers ":" Cached ":" SReclaimable ":" Shmem}' /proc/meminfo) + +echo "$meminfo" | + while IFS=: read -r t a f b c sr sh; do + memfree=$(echo "$a $t" | awk '{printf "%.3f", ($1 / $2) * 100}') + memused=$(echo "$memfree" | awk '{printf "%.3f", (100 - $1)}') + + # Percentage values + # TODO: other values, controllable by flags? + echo "$memfree $memused" + done |
