diff options
Diffstat (limited to '.local')
| -rwxr-xr-x | .local/bin/scripts/Heads-Up-Display | 13 | ||||
| -rw-r--r-- | .local/bin/scripts/README.md | 1 | ||||
| -rwxr-xr-x | .local/bin/scripts/bspwm_resize.sh | 67 | ||||
| -rwxr-xr-x | .local/bin/scripts/colors.sh | 78 | ||||
| -rwxr-xr-x | .local/bin/scripts/cryptocheck | 31 | ||||
| -rwxr-xr-x | .local/bin/scripts/cryptonotify | 19 | ||||
| -rwxr-xr-x | .local/bin/scripts/ffmpeg | 24 | ||||
| -rwxr-xr-x | .local/bin/scripts/killandnotify | 4 | ||||
| -rwxr-xr-x | .local/bin/scripts/layer.sh | 24 | ||||
| -rwxr-xr-x | .local/bin/scripts/opacity-change.sh | 34 | ||||
| -rwxr-xr-x | .local/bin/scripts/powermenu | 38 | ||||
| -rwxr-xr-x | .local/bin/scripts/scratchpad | 30 |
12 files changed, 363 insertions, 0 deletions
diff --git a/.local/bin/scripts/Heads-Up-Display b/.local/bin/scripts/Heads-Up-Display new file mode 100755 index 0000000..d90c7d3 --- /dev/null +++ b/.local/bin/scripts/Heads-Up-Display @@ -0,0 +1,13 @@ +#!/bin/sh + +id=$(xdotool search --class Heads-Up-Display); +if [ -z "$id" ]; then + alacritty --class "Heads-Up-Display" -e tmux new-session -A -s HUD -e bash > /dev/null 2>&1 & +else + if [ ! -f /tmp/hide_hud ]; then + touch /tmp/hide_hud && xdo hide "$id" + elif [ -f /tmp/hide_hud ]; then + rm /tmp/hide_hud && xdo show "$id" + fi +fi + diff --git a/.local/bin/scripts/README.md b/.local/bin/scripts/README.md new file mode 100644 index 0000000..458b3cc --- /dev/null +++ b/.local/bin/scripts/README.md @@ -0,0 +1 @@ +# scripts diff --git a/.local/bin/scripts/bspwm_resize.sh b/.local/bin/scripts/bspwm_resize.sh new file mode 100755 index 0000000..29ab5cf --- /dev/null +++ b/.local/bin/scripts/bspwm_resize.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +size=${2:-'10'} +dir=$1 + +# Find current window mode +is_tiled() { +bspc query -T -n | grep -q '"state":"tiled"' +} +# If the window is floating, move it +if ! is_tiled; then +#only parse input if window is floating,tiled windows accept input as is + case "$dir" in + west) switch="-w" + sign="-" + ;; + east) switch="-w" + sign="+" + ;; + north) switch="-h" + sign="-" + ;; + south) switch="-h" + sign="+" + ;; + esac + xdo resize ${switch} ${sign}${size} + +# Otherwise, window is tiled: switch with window in given direction +else + case "$dir" in + west) bspc node @west -r -$size || bspc node @east -r -${size} + ;; + east) bspc node @west -r +$size || bspc node @east -r +${size} + ;; + north) bspc node @south -r -$size || bspc node @north -r -${size} + ;; + south) bspc node @south -r +$size || bspc node @north -r +${size} + ;; + esac +fi + +##!/bin/bash +# +#[ "$#" -eq 3 ] || { echo "Needs exactly three arguments."; exit 1; } +# +#motion="$1" +#direction="$2" +#size="$3" +# +#if [ "$motion" = 'expand' ]; then +# # These expand the window's given side +# case "$direction" in +# north) bspc node -z top 0 -"$size" ;; +# east) bspc node -z right "$size" 0 ;; +# south) bspc node -z bottom 0 "$size" ;; +# west) bspc node -z left -"$size" 0 ;; +# esac +#else +# # These contract the window's given side +# case "$direction" in +# north) bspc node -z top 0 "$size" ;; +# east) bspc node -z right -"$size" 0 ;; +# south) bspc node -z bottom 0 -"$size" ;; +# west) bspc node -z left "$size" 0 ;; +# esac +#fi diff --git a/.local/bin/scripts/colors.sh b/.local/bin/scripts/colors.sh new file mode 100755 index 0000000..fc1c10c --- /dev/null +++ b/.local/bin/scripts/colors.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +colors=$@ +for (( n=0; n < $colors; n++ )) do + printf " [%d] $(tput setaf $n)%s$(tput sgr0)" $n "Hello World! +" +done +PADDING='Padding' + +main() { + local xterm_start=0 \ + xterm_width=8 \ + xterm_height=2 + + local cube_start=$((xterm_start + xterm_width * xterm_height)) \ + cube_width=6 \ + cube_height=$((6 * 6)) + + local greys_start=$((cube_start + cube_width * cube_height)) \ + greys_width=8 \ + greys_height=3 + + color_block $xterm_start $xterm_width $xterm_height + color_block $cube_start $cube_width $cube_height use_padding + color_block $greys_start $greys_width $greys_height + echo +} + +color_block() { + local start=$1 width=$2 height=$3 use_padding=$4 + local max s color_nums colors + + max=$((start + width * height - 1)) + + echo + for s in $(seq $start $width $max); do + color_nums=$(seq $s $((s + width - 1))) + colors="${use_padding:+$PADDING }${color_nums}${use_padding:+ $PADDING}" + + printf '%s%s %s%s\n' \ + "$(fg_bars $colors)" $ansi_reset \ + "$(bg_bars $colors)" $ansi_reset + done +} + +fg_bars() { + for color in $@; do + color_bar ansi_fg $color '' + done +} + +bg_bars() { + for color in $@; do + color_bar ansi_bg $color ' ' + done +} + +color_bar() { + local ansi=$1 color=$2 trail=$3 + + if [ "$color" == $PADDING ]; then + printf '%s %s' $ansi_reset "$trail" + else + local color_seq=$($ansi $color) + printf '%s %03d%s' $color_seq $color "$trail" + fi +} + +ansi_reset=$'\033[0m' + +ansi_fg() { + printf '\033[38;5;%dm' $1 +} + +ansi_bg() { + printf '\033[48;5;%dm' $1 +} + +main diff --git a/.local/bin/scripts/cryptocheck b/.local/bin/scripts/cryptocheck new file mode 100755 index 0000000..02ba42d --- /dev/null +++ b/.local/bin/scripts/cryptocheck @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +if [ ! -d ~/.cache/crypto ]; then + mkdir ~/.cache/crypto +fi +ticker=(BTC ETH ADA DOT SOL XMR) + +for currency in "${ticker[@]}"; do + echo "$currency" +done | while read coin + do + price=$(curl rate.sx/1$coin) + if [ $coin = "BTC" ]; then + icon= + elif [ $coin = "ETH" ]; then + icon= + elif [ $coin = "ADA" ]; then + icon= + elif [ $coin = "DOT" ]; then + icon= + elif [ $coin = "SOL" ]; then + icon= + elif [ $coin = "XMR" ]; then + icon= + fi + + echo "$icon $coin: $price" > ~/.cache/crypto/$coin + + done + +date > ~/.cache/crypto/time + diff --git a/.local/bin/scripts/cryptonotify b/.local/bin/scripts/cryptonotify new file mode 100755 index 0000000..47883c3 --- /dev/null +++ b/.local/bin/scripts/cryptonotify @@ -0,0 +1,19 @@ +#!/bin/sh +source cryptocheck +Output= +for file in ~/.cache/crypto/* +do + if [ ! -z "$Output" ]; then + if [ ! $(basename $file) = "time" ]; then + Output="$Output\n$(cat $file)" + fi + else + if [ ! $(basename $file) = "time" ]; then + Output="$Output$(cat $file)" + fi + fi + +done + +Output="$Output\n$(cat ~/.cache/crypto/time)" +notify-send "Crypto Prices" "$Output" diff --git a/.local/bin/scripts/ffmpeg b/.local/bin/scripts/ffmpeg new file mode 100755 index 0000000..2258fbd --- /dev/null +++ b/.local/bin/scripts/ffmpeg @@ -0,0 +1,24 @@ +#!/bin/bash + +# audio +A="$(pactl list sources | grep 'analog.*monitor' | awk '{print $2}')" +# screen size +S="$(xdpyinfo | grep dimensions | awk '{print $2}')" +# file name +N="$(date +"%m-%d-%Y_%I:%M%p").mp4" + +# Desktop audio + screen recording +ffmpeg \ +-s "$S" -r 25 -f x11grab -i :0.0+0,0 \ +-ac 2 ~/"$N" + +# ffmpeg can output high quality GIF. Before you start it is always recommended to use a recent version: download or compile. + +# ffmpeg -ss 30 -t 3 -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif + +# This example will skip the first 30 seconds (-ss 30) of the input and create a 3 second output (-t 3). +# fps filter sets the frame rate. A rate of 10 frames per second is used in the example. +# scale filter will resize the output to 320 pixels wide and automatically determine the height while preserving the aspect ratio. The lanczos scaling algorithm is used in this example. +# palettegen and paletteuse filters will generate and use a custom palette generated from your input. These filters have many options, so refer to the links for a list of all available options and values. Also see the Advanced options section below. +# split filter will allow everything to be done in one command and avoids having to create a temporary PNG file of the palette. +# Control looping with -loop output option but the values are confusing. A value of 0 is infinite looping, -1 is no looping, and 1 will loop once meaning it will play twice. So a value of 10 will cause the GIF to play 11 times. diff --git a/.local/bin/scripts/killandnotify b/.local/bin/scripts/killandnotify new file mode 100755 index 0000000..2e7222e --- /dev/null +++ b/.local/bin/scripts/killandnotify @@ -0,0 +1,4 @@ +#!/bin/sh +# Kills an application and sends a notification that it's been killed + +killall "$1" && notify-send "$1" "$2" diff --git a/.local/bin/scripts/layer.sh b/.local/bin/scripts/layer.sh new file mode 100755 index 0000000..4b17ed1 --- /dev/null +++ b/.local/bin/scripts/layer.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +current_layer="$(bspc query -T -n | jq -r '.client.layer')" +case $1 in + +|-) + declare -A _layers=( [below]=0 [normal]=1 [above]=2 ) + layers=( below normal above ) + maxl=$(( ${#layers[@]} - 1 )) + current_layer="$(bspc query -T -n | jq -r '.client.layer')" + i=$(( ${_layers[$current_layer]} $1 1 )) + if [[ $i -lt 0 ]]; then + i=0 + elif [[ $i -gt $maxl ]]; then + i=$maxl + fi + #cycle? nah + #i=$(( (${_layers[$current_layer]} + ${#layers[@]} ${1} 1) % ${#layers[@]} )) + new_layer="${layers[$i]}" + ;; + *) + new_layer="$(bspc query -T -n | jq -r '.client.lastLayer')" + ;; +esac +[[ "$current_layer" != "$new_layer" ]] && bspc node -l "$new_layer" diff --git a/.local/bin/scripts/opacity-change.sh b/.local/bin/scripts/opacity-change.sh new file mode 100755 index 0000000..b509936 --- /dev/null +++ b/.local/bin/scripts/opacity-change.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -eu +[[ -n ${DEBUG:-} ]] && set -x + +#### Example alacritty.yml usage +#key_bindings: +# - { key: N, mods: Control|Shift, action: SpawnNewInstance } +# - { key: O, mods: Control|Shift, command: { program: "opacity-change.sh", args: ["-"] } } +# - { key: P, mods: Control|Shift, command: { program: "opacity-change.sh", args: ["+"] } } + + +operation="${1:-}${2:-}" # Arg #1 & #2 (in case the user misinterpreted a space in the usage), Default '' +step="${operation:1}" # Substring from char index 1 +step="${step:-1}" # Default '1' +operation="${operation:0:1}" # Substring from char index 0 length of 1 +config_file="$HOME/.config/alacritty/alacritty.yml" +config_field="opacity" +tmp_file="/tmp/$(basename $config_file).$(date +%s)" +current_value=$(sed 's/#.*//g; /\b'"$config_field"':/!d; s/.*: \?//' < "$config_file") + +case $operation in +"-") + verb="Decreasing" ;; +"+") + verb="Increasing" ;; +*) + echo "Usage: ${BASH_SOURCE[0]} (-|+)[int]"; exit 255 ;; +esac + +new_value="$(awk '{n=$1+$2/10; print (n<0 ? 0 : n>1 ? 1 : n)}' <<<"$current_value $operation$step")" +echo "$verb $config_field from $current_value to $new_value" >&2 +cp "$config_file" "$tmp_file" +sed "s/\b$config_field:.*/$config_field: $new_value/" "$tmp_file" > "$config_file" + diff --git a/.local/bin/scripts/powermenu b/.local/bin/scripts/powermenu new file mode 100755 index 0000000..7bd913e --- /dev/null +++ b/.local/bin/scripts/powermenu @@ -0,0 +1,38 @@ +#!/bin/bash + +# display a power menu to: shutdown, reboot, +# lock, logout, and suspend. This script can be +# executed by clicking on the polybar powermenu module +# or with a keyboard shortcut + +# options to be displayed +shutdown=" Shutdown" +reboot=" Reboot" +lock=" Lock" +logout=" Logout" +suspend=" Suspend" + +uptime=$(uptime -p | sed -e 's/up //g') + +# options passed into variable +options="$shutdown\n$reboot\n$lock\n$logout\n$suspend" + +chosen="$(echo -e "$options" | rofi -theme ~/.config/rofi/styles/powermenu.rasi -lines 5 -dmenu -p "$uptime")" + +case $chosen in +$shutdown) + systemctl poweroff + ;; +$reboot) + systemctl reboot + ;; +$lock) + betterlockscreen --lock dimblur + ;; +$logout) + bspc quit + ;; +$suspend) + systemctl suspend + ;; +esac diff --git a/.local/bin/scripts/scratchpad b/.local/bin/scripts/scratchpad new file mode 100755 index 0000000..331f8a2 --- /dev/null +++ b/.local/bin/scripts/scratchpad @@ -0,0 +1,30 @@ +#!/bin/sh + +#sid=$(wmctrl -lx | grep scratch.scratchpad| cut -d' ' -f1| head -1) \ +#&& [ -z "$(echo $sid)" ] \ +# && alacritty -t scratchpad --class scratch,scratchpad -e tmux new-session -A -s scratchpad +# & sleep 1 \ +# && sid=$(wmctrl -lx | grep scratch.scratchpad| cut -d' ' -f1| head -1) \ +# && echo "$sid" > /tmp/scratchID ; +if id="$(xdo id -N scratch)" + then bspc node "$id" -g hidden -f + else alacritty --class scratch,scratchpad -e tmux new-session -A -s scratch -e bash > /dev/null 2>&1 & + #else alacritty --class scratch,scratchpad -e tmux new-session -A -s scratch -e bash > /dev/null 2>&1 & +fi + +#id=$(xdotool search --class scratchpad); +#if [ -z "$id" ]; then +# alacritty --class scratch,scratchpad -e tmux new-session -A -s scratch; +#else +# if [ ! -f /tmp/hide_scratch ]; then +# touch /tmp/hide_scratch && xdo hide "$id" +# elif [ -f /tmp/hide_scratch ]; then +# rm /tmp/hide_scratch && xdo show "$id" +# fi +#fi + +# alacritty -t scratchpad --class scratch,scratchpad -e zsh -c "zsh tmux attach -t scratch || tmux new -s scratch"; +# st -c scratchy -e tmux attach -t scratchy || tmux new -s scratchy; +# && alacritty -t scratchpad --class scratch,scratchpad -e zsh -c "zsh tmux attach -t scratch || tmux new -s scratch"\ +# alacritty --class scratch,scratchpad -e tmux attach -t scratch || tmux new -s scratch; + |
