Browse Source

update screens to be more configurable

master
Cian Butler 2 years ago
parent
commit
008dfc80c1
Signed by: butlerx GPG Key ID: B37CA765BAA89170
11 changed files with 388 additions and 146 deletions
  1. +46
    -46
      2048
  2. +5
    -5
      check
  3. +37
    -37
      collectnetworkinfo
  4. +21
    -0
      colors.sh
  5. +213
    -0
      ginh
  6. +4
    -4
      killrenegade
  7. +2
    -2
      minesweeper
  8. +1
    -1
      pass-gen
  9. +53
    -45
      screens
  10. +5
    -5
      swappy.sh
  11. +1
    -1
      vpn

+ 46
- 46
2048 View File

@@ -46,18 +46,18 @@ function _seq() {
local max
local inc=1
case $# in
1) ((max = $1)) ;;
1) ((max = "$1")) ;;
2)
((cur = $1))
((max = $2))
((cur = "$1"))
((max = "$2"))
;;
3)
((cur = $1))
((inc = $2))
((max = $3))
((cur = "$1"))
((inc = "$2"))
((max = "$3"))
;;
esac
while test $max -ge $cur; do
while test "$max" -ge "$cur"; do
printf "%i " "$cur"
((cur += inc))
done
@@ -70,14 +70,14 @@ function print_board() {
printf "Board status:\\n" >&3
printf "\\n"
printf '/------'
for l in $(_seq 1 "$index_max"); do
for l in "$(_seq 1 "$index_max")"; do
printf '+------'
done
printf '\\\n'
for l in $(_seq 0 "$index_max"); do
for l in "$(_seq 0 "$index_max")"; do
printf '|'
for m in $(_seq 0 "$index_max"); do
if ((${board[l * $board_size + m]})); then
for m in "$(_seq 0 "$index_max")"; do
if (("${board[l * $board_size + m]}")); then
if ( (last_added=(l*board_size+m)) | (first_round=(l*board_size+m))); then
printf '\033[1m\033[31m %4d \033[0m|' "${board[l * $board_size + m]}"
else
@@ -91,7 +91,7 @@ function print_board() {
done
((l == index_max)) || {
printf '\n|------'
for j in $(_seq 1 "$index_max"); do
for j in "$(_seq 1 "$index_max")"; do
printf '+------'
done
printf '|\n'
@@ -99,7 +99,7 @@ function print_board() {
}
done
printf '\n\\------'
for l in $(_seq 1 "$index_max"); do
for l in "$(_seq 1 "$index_max")"; do
printf '+------'
done
printf '/\n'
@@ -117,7 +117,7 @@ function generate_piece() {
((pos = RANDOM % fields_total))
((board[pos])) || {
((value = RANDOM % 10 ? 2 : 4))
board[$pos]=$value
board["$pos]=$value"
last_added=$pos
printf "Generated new piece with value %i at position [%i]\\n" "$value" "$pos" >&3
break
@@ -142,29 +142,29 @@ function generate_piece() {
function push_pieces() {
case $4 in
"up")
((first = $2 * board_size + $1))
((second = ($2 + $3) * board_size + $1))
((first = "$2" * board_size + "$1"))
((second = ("$2" + "$3") * board_size + "$1"))
;;
"down")
((first = (index_max - $2) * board_size + $1))
((second = (index_max - $2 - $3) * board_size + $1))
((first = (index_max - "$2") * board_size + "$1"))
((second = (index_max - "$2" - "$3") * board_size + "$1"))
;;
"left")
((first = $1 * board_size + $2))
((second = $1 * board_size + ($2 + $3)))
((first = "$1" * board_size + "$2"))
((second = "$1" * board_size + ("$2" + "$3")))
;;
"right")
((first = $1 * board_size + (index_max - $2)))
((second = $1 * board_size + (index_max - $2 - $3)))
((first = "$1" * board_size + (index_max - "$2")))
((second = "$1" * board_size + (index_max - "$2" - "$3")))
;;
esac
((${board[$first]})) || {
((${board[$second]})) && {
(("${board[$first]}")) || {
(("${board[$second]}")) && {
if test -z "$5"; then
board[$first]=${board[$second]}
board["$first]=${board[$second]}"
((board["$second"] = 0))
((change = 1))
printf "move piece with value %s from [%s] to [%s]\\n" ${board[$first]} $second $first >&3
printf "move piece with value %s from [%s] to [%s]\\n" "${board[$first]}" "$second" "$first" >&3
else
((moves++))
fi
@@ -172,16 +172,16 @@ function push_pieces() {
}
return
}
((${board[$second]})) && ((flag_skip = 1))
if ((${board[$first]} == board[second])); then
(("${board[$second]}")) && ((flag_skip = 1))
if (("${board[$first]}" == board[second])); then
if test -z "$5"; then
((board[first] *= 2))
((board[first] == target)) && end_game 1
((board[second] = 0))
((pieces -= 1))
((change = 1))
((score += ${board[$first]}))
printf "joined piece from [%s] with [%s], new value=%s\\n" $second $first ${board[$first]} >&3
((score += "${board[$first]}"))
printf "joined piece from [%s] with [%s], new value=%s\\n" "$second" "$first" "${board[$first]}" >&3
else
((moves++))
fi
@@ -190,11 +190,11 @@ function push_pieces() {

function apply_push() {
printf "\\n\\ninput: %s key\\n" "$1" >&3
for i in $(_seq 0 "$index_max"); do
for j in $(_seq 0 "$index_max"); do
for i in "$(_seq 0 "$index_max")"; do
for j in "$(_seq 0 "$index_max")"; do
flag_skip=0
((increment_max = index_max - j))
for k in $(_seq 1 $increment_max); do
for k in "$(_seq 1 "$increment_max")"; do
((flag_skip)) && break
push_pieces "$i" "$j" "$k" "$1" "$2"
done
@@ -253,12 +253,12 @@ function reload_game() {
return
fi
board=$(cat "$config_dir/board")
board_size=($(cat "$config_dir/board_size"))
board=($(cat "$config_dir/board"))
pieces=($(cat "$config_dir/pieces"))
first_round=($(cat "$config_dir/first_round"))
target=($(cat "$config_dir/target"))
score=($(cat "$config_dir/score"))
board_size=("$(cat "$config_dir/board_size")")
board=("$(cat "$config_dir/board")")
pieces=("$(cat "$config_dir/pieces")")
first_round=("$(cat "$config_dir/first_round")")
target=("$(cat "$config_dir/target")")
score=("$(cat "$config_dir/score")")

fields_total=$((board_size * board_size))
index_max=$((board_size - 1))
@@ -269,16 +269,16 @@ function end_game() {
end_time=$(date +%s)
((total_time = end_time - start_time))
print_board
printf "Your score: %s\\n" ${score[0]}
printf "Your score: %s\\n" "${score[0]}"
printf "This game lasted "
if date --version >/dev/null 2>&1; then
date -u -d @${total_time} +%T
date -u -d @"$total_time" +%T
else
date -u -r ${total_time} +%T
date -u -r "$total_time" +%T
fi
stty echo
(($1)) && {
printf "Congratulations you have achieved %s\\n" ${target[0]}
(("$1")) && {
printf "Congratulations you have achieved %s\\n" "${target[0]}"
exit 0
}
( (test -z "$2")) && {
@@ -350,14 +350,14 @@ done
#init board
((fields_total = board_size * board_size))
((index_max = board_size - 1))
for i in $(_seq 0 $fields_total); do board[$i]="0"; done
for i in "$(_seq 0 "$fields_total")"; do board["$i]=0"; done
((pieces = 0))
generate_piece
first_round=${last_added[0]}
generate_piece

#load saved game if flag is set
if test $reload_flag = "1"; then
if test "$reload_flag" = "1"; then
reload_game
fi



+ 5
- 5
check View File

@@ -27,12 +27,12 @@ function position() {
}

function monitor() {
local url=$1
local url="$1"
local p=$((START_CURSOR + $2 + 1))

# -w "$GREEN%{http_code}$RESET $url \\033[${p};${TIMING_COL}f%{time_total}s TTFB: %{time_connect} + %{time_starttransfer} (%{size_download})" \

echo -e "\\033[${p};0f$(curl "$url" --compress -s -o /dev/null -w \
echo -e "\\033[$p;0f$(curl "$url" --compress -s -o /dev/null -w \
"%{http_code}|%{time_total}|%{time_pretransfer}|%{time_starttransfer}\\n" |
sed -n '/^/ s///p' |
while IFS='|' read -r http_code time_total time_pretransfer time_starttransfer; do
@@ -42,8 +42,8 @@ function monitor() {
http_code="$GREEN$http_code$RESET"
fi
TTFB=$(echo -e "$time_starttransfer $time_pretransfer" | awk '{ printf "%.3fs", $1 - $2 }')
echo -e "$http_code $url \\033[${p};${TIMING_COL}f${time_total}s (TTFB $TTFB)"
done)\\n\\033[${LAST_CURSOR};0f" &
echo -e "$http_code $url \\033[$p;${TIMING_COL}f${time_total}s (TTFB $TTFB)"
done)\\n\\033[$LAST_CURSOR;0f" &

PIDS=("${PIDS[@]}" "$!")
}
@@ -59,7 +59,7 @@ declare -a URLS

if [ -t 0 ]; then
if [ $# -eq 0 ]; then
echo -e "Usage:\\n\\n ${RED}check${RESET} <url>\\n cat urls.txt | \\033[1mcheck${RESET}\\n"
echo -e "Usage:\\n\\n ${RED}check$RESET <url>\\n cat urls.txt | \\033[1mcheck$RESET\\n"
exit 1
else
URLS=("$1")


+ 37
- 37
collectnetworkinfo View File

@@ -17,72 +17,72 @@ OUTPUT="network.$(date +'%d-%m-%y').info.txt"
## Email info to?? ##
SUPPORT_ID="your_name@service_provider.com"
chk_root() {
local meid=$(id -u)
if [ $meid -ne 0 ]; then
local meid="$(id -u)"
if [ "$meid" -ne 0 ]; then
echo "You must be root user to run this tool"
exit 999
fi
}
write_header() {
echo "---------------------------------------------------" >>$OUTPUT
echo "$@" >>$OUTPUT
echo "---------------------------------------------------" >>$OUTPUT
echo "---------------------------------------------------" >>"$OUTPUT"
echo "$@" >>"$OUTPUT"
echo "---------------------------------------------------" >>"$OUTPUT"
}
dump_info() {
echo "* Hostname: $(hostname)" >$OUTPUT
echo "* Run date and time: $(date)" >>$OUTPUT
echo "* Hostname: $(hostname)" >"$OUTPUT"
echo "* Run date and time: $(date)" >>"$OUTPUT"
write_header "Linux Distro"
echo "Linux kernel: $(uname -mrs)" >>$OUTPUT
$LSB -a >>$OUTPUT
[ -x ${HWINF} ] && write_header "${HWINF}"
[ -x ${HWINF} ] && ${HWINF} >>$OUTPUT
[ -x ${HWINF} ] && write_header "${HWINF}"
[ -x ${HWINF} ] && ${HWINF} >>$OUTPUT
echo "Linux kernel: $(uname -mrs)" >>"$OUTPUT"
"$LSB" -a >>"$OUTPUT"
[ -x "$HWINF" ] && write_header "$HWINF"
[ -x "$HWINF" ] && "$HWINF" >>"$OUTPUT"
[ -x "$HWINF" ] && write_header "$HWINF"
[ -x "$HWINF" ] && "$HWINF" >>"$OUTPUT"
write_header "PCI Devices"
${LSPCI} -v >>$OUTPUT
"$LSPCI" -v >>"$OUTPUT"
write_header "$IFCFG Output"
$IFCFG >>$OUTPUT
"$IFCFG" >>"$OUTPUT"
write_header "Kernel Routing Table"
$ROUTE -n >>$OUTPUT
"$ROUTE" -n >>"$OUTPUT"
write_header "Network Card Drivers Configuration $DRVCONF"
[ -f $DRVCONF ] && grep eth $DRVCONF >>$OUTPUT || echo "Error $DRVCONF file not found." >>$OUTPUT
[ -f "$DRVCONF" ] && grep eth "$DRVCONF" >>"$OUTPUT" || echo "Error $DRVCONF file not found." >>"$OUTPUT"
write_header "DNS Client $DNSCLIENT Configuration"
[ -f $DNSCLIENT ] && cat $DNSCLIENT >>$OUTPUT || echo "Error $DNSCLIENT file not found." >>$OUTPUT
[ -f "$DNSCLIENT" ] && cat "$DNSCLIENT" >>"$OUTPUT" || echo "Error $DNSCLIENT file not found." >>"$OUTPUT"
write_header "Network Configuration File"
for f in $NETCFC; do
if [ -f $f ]; then
echo "** $f **" >>$OUTPUT
cat $f >>$OUTPUT
for f in "$NETCFC"; do
if [ -f "$f" ]; then
echo "** $f **" >>"$OUTPUT"
cat "$f" >>"$OUTPUT"
else
echo "Error $f not found." >>$OUTPUT
echo "Error $f not found." >>"$OUTPUT"
fi
done
write_header "Network Aliase File"
for f in $NETALIASCFC; do
if [ -f $f ]; then
echo "** $f **" >>$OUTPUT
cat $f >>$OUTPUT
for f in "$NETALIASCFC"; do
if [ -f "$f" ]; then
echo "** $f **" >>"$OUTPUT"
cat "$f" >>"$OUTPUT"
else
echo "Error $f not found." >>$OUTPUT
echo "Error $f not found." >>"$OUTPUT"
fi
done
write_header "Network Static Routing Configuration"
for f in $NETSTATICROUTECFC; do
if [ -f $f ]; then
echo "** $f **" >>$OUTPUT
cat $f >>$OUTPUT
for f in "$NETSTATICROUTECFC"; do
if [ -f "$f" ]; then
echo "** $f **" >>"$OUTPUT"
cat "$f" >>"$OUTPUT"
else
echo "Error $f not found." >>$OUTPUT
echo "Error $f not found." >>"$OUTPUT"
fi
done
write_header "IP4 Firewall Configuration"
$IP4FW -L -n >>$OUTPUT
"$IP4FW" -L -n >>"$OUTPUT"
write_header "IP6 Firewall Configuration"
$IP6FW -L -n >>$OUTPUT
"$IP6FW" -L -n >>"$OUTPUT"
write_header "Network Stats"
$NETSTAT -s >>$OUTPUT
"$NETSTAT" -s >>"$OUTPUT"
write_header "Network Tweaks via $SYSCTL"
[ -f $SYSCTL ] && cat $SYSCTL >>$OUTPUT || echo "Error $SYSCTL not found." >>$OUTPUT
[ -f "$SYSCTL" ] && cat "$SYSCTL" >>"$OUTPUT" || echo "Error $SYSCTL not found." >>"$OUTPUT"
echo "The Network Configuration Info Written To $OUTPUT. Please email this file to $SUPPORT_ID."
}
chk_root


+ 21
- 0
colors.sh View File

@@ -0,0 +1,21 @@
#!/bin/bash
# shellcheck disable=SC1117
export black="\033[0;30m"
export red="\033[0;31m"
export green="\033[0;32m"
export brown="\033[0;33m"
export blue="\033[0;34m"
export purple="\033[0;35m"
export cyan="\033[0;36m"
export lgray="\033[0;37m"

export darkgray="\033[1;30m"
export lred="\033[1;31m"
export lgreen="\033[1;32m"
export yellow="\033[1;33m"
export lblue="\033[1;34m"
export lpurple="\033[1;35m"
export lcyan="\033[1;36m"
export white="\033[1;37m"

export nocolor='\033[0m' # no color

+ 213
- 0
ginh View File

@@ -0,0 +1,213 @@
#!/usr/bin/env bash

declare -a counts freq cmds filters
line_len=$(($(/usr/bin/tput cols) - 2)) # get terminal width
num_entries=15
chart_char='='
OPTIND=1 # reset getopts
max_len=0
ppid=$PPID

zsh_extended_filter_string="^:[0-9 ]*:[0-9];"
fish_filter_string="^\\- cmd: "
sudo_filter_string="^sudo "

# define colors
source ./colors.sh

color1=$lcyan
color2=$lpurple

function debug() {
echo "commit: $(git rev-parse HEAD)"
echo "uname: $(uname -a)"
get_shell
echo "shell: $shell"
get_history_file
echo "histfile: $histfile"
}

function show_help() {
echo "usage: $0 [-h] [-d] [-n entries] [-f hist_file] [-c chart_char] [-l line_len]"
}

function err() {
echo "$1"
exit 1
}

function separator() {
for (( n=0; n<=line_len; n++ ))
do
# shellcheck disable=SC2059
printf "$white-$nocolor"
done
printf "\\n"
}

# generic shell formatting filter
function shell_filter() {
if grep -E "$2" <<< "$1" >/dev/null; then
grep -E "$2" <<< "$1" \
| sed -e "s/$2//g"
else
echo "$1"
fi
}

# if match fish history format, remove fish formating
function fish_filter() {
shell_filter "$1" "$fish_filter_string"
}

# if match zsh_extended history format, remove zsh_extended formating
function zsh_extended_filter() {
shell_filter "$1" "$zsh_extended_filter_string"
}

# remove 'sudo's
function sudo_filter() {
sed -e "s/$sudo_filter_string//g" <<< "$1"
}

# get command name, sort, and count
function final_filter() {
awk '{print $1}' <<< "$1" \
| sort \
| uniq -c \
| sort -rn
}

# check the shell used to instantiate ginh
function get_shell() {
shell=$(ps -p "$ppid" -o comm= | sed -e 's/^-//')
if [ -z "$shell" ]; then
err "unable to autodetect shell, try specifying a file using -f"
fi
}

# get location of history file for the shell used to instantiate ginh
function get_history_file() {
get_shell
if [ "$shell" == "fish" ]; then
# fish history cannot be changed, determine location based on version
fish_version="$(fish -v | awk '{print $3}')"
if version_gt "$fish_version" "2.3.0"; then
histfile="$HOME/.local/share/fish/fish_history"
else
histfile="$HOME/.config/fish/fish_history"
fi
else
histfile=$("$shell" -ci "echo \$HISTFILE")
fi
if [ -z "$histfile" ]; then
err "unable to autodetect history file, try specifying a file using -f"
fi
}

# test if the first argument is greater than the second argument,
# following versioning logic
function version_gt() {
test "$(sort -V <<< "$@" | head -n 1)" != "$1"
}

while getopts "h?dn:f:c:l:t:" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
d)
debug
exit 0
;;
n)
num_entries=$OPTARG
;;
f)
histfile=$OPTARG
;;
c)
chart_char="$OPTARG"
;;
l)
line_len=$OPTARG
;;
t)
ppid=$OPTARG
;;
esac
done

shift $((OPTIND-1))

[ "${1:-}" = "--" ] && shift

if [ -z "$histfile" ]; then
get_history_file
fi

filters+=("fish_filter")
filters+=("zsh_extended_filter")
filters+=("sudo_filter")
filters+=("final_filter")

calc=$(grep -v -E '^\s*$|^\s+' "$histfile")
for (( n=0; n<${#filters[@]}; n++ )); do
calc=$("${filters[n]}" "$calc")
done

# choose smaller of requested number of entries and actual number
num_lines=$(wc -l <<< "$calc")
num_entries=$((num_lines < num_entries
? num_lines
: num_entries))

echo "entries=$num_entries, file=$histfile, char=$chart_char, len=$line_len"

for (( n=0; n<num_entries; n++ )); do
# gather counts and cmds
cmds[n]="$(sed -ne "$((1 + n))p" <<< "$calc")" # isolate line n+1
counts[n]="$(awk '{print $1}' <<< "${cmds[n]}")"
s=$(awk '{print $2}' <<< "${cmds[n]}")
max_len=$((
${#s} > max_len
? ${#s}
: max_len
))
done

max_len=$((max_len + 1))

for (( n=0; n<num_entries; n++ )); do
# calculate frequencies
(( freq[n]=counts[n] * \
$((line_len - max_len - ${#counts[0]} - 2)) \
/ counts[0] ))
done

separator

for (( n=0; n<num_entries; n++ )); do
if [[ $((n % 2)) == 0 ]]; then
color=$color1
else
color=$color2
fi
s=$(awk '{print $2}' <<< "${cmds[n]}")
for (( m=0; m<=max_len-${#s} - 2; m++ )); do
printf " "
done
printf "$color%s$nocolor " "$(awk '{print $2}' <<< "${cmds[n]}")"

for (( m=0; m<=freq[n]; m++ )); do
printf "$color%s$nocolor" "$chart_char"
done

printf " "
printf "$color%s$nocolor" "${counts[n]}"

printf "\\n"
done

separator

+ 4
- 4
killrenegade View File

@@ -109,7 +109,7 @@ done
exit 2
}

last[0]=$(date +'%s')
last[0]="$(date +'%s')"
[[ "$logfile" && ! -e "$logfile" ]] && touch "$logfile"
[[ "$logfile" && -x "$selfdir/killstatistic.awk" ]] || htmldir=''
[[ "$htmldir" && ! -e "$htmldir" ]] && mkdir -p "$htmldir"
@@ -150,7 +150,7 @@ while :; do

((cpui > mcpu[i] || memi > mmem[i])) && {
((verb)) && echo -n "kill ${comm[i]} ( $pid ) "
for sig in ${sign[i]}; do
for sig in "${sign[i]}"; do
((verb)) && echo -n "$sig... "
kill -"$sig" "$pid" && break
done
@@ -158,14 +158,14 @@ while :; do
[[ "$logfile" ]] && echo -e "$user\\t$(date +'%Y-%m-%d %H:%M:%S')\\t$cpu\\t$mem\\t${comm[$i]}\\t$sig" >>"$logfile"
}
done
last[i]=$now
last[i]="$now"
fi
done

[[ "$htmldir" ]] && ((last[0] + build <= now)) && {
((verb)) && echo 'build'
"$selfdir/killstatistic.awk" -v htmldir="$htmldir" "$logfile" &
last[0]=$now
last[0]="$now"
}

next=0


+ 2
- 2
minesweeper View File

@@ -66,7 +66,7 @@ function gameover() {

function makestep() {
local i j
local sx=${1:-$cx} sy=${2:-$cy}
local sx="${1:-$cx}" sy="${2:-$cy}"
[[ "${board[sy * mx + sx]}" != @(9|10|11) ]] && return
((bomb[cy * mx + cx] == 1)) && {
gameover
@@ -86,7 +86,7 @@ function makestep() {
for ((i = -1; i <= 1; i++)); do for ((j = -1; j <= 1; j++)); do
(((i != 0 || j != 0) && sx + i >= 0 && sx + i < mx && sy + j >= 0 && sy + j < my)) && ((bomb[(sy + j) * mx + (sx + i)] == 1)) && ((n++))
done; done
board[sy * mx + sx]=$n
board[sy * mx + sx]="$n"
((n)) || {
for ((i = -1; i <= 1; i++)); do for ((j = -1; j <= 1; j++)); do
(((i != 0 || j != 0) && sx + i >= 0 && sx + i < mx && sy + j >= 0 && sy + j < my)) && makestep $((sx + i)) $((sy + j))


+ 1
- 1
pass-gen View File

@@ -1,5 +1,5 @@
#! /usr/bin/env bash

characters="${PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS:-[:alnum:]}"
read -r -n 12 pass < <(LC_ALL=C tr -dc "$characters" </dev/urandom)
read -r -n 30 pass < <(LC_ALL=C tr -dc "$characters" </dev/urandom)
echo -n "$pass" | xsel -b

+ 53
- 45
screens View File

@@ -1,10 +1,11 @@
#!/usr/bin/env bash

if [[ $DEBUG == 'true' ]]; then
set -exo pipefail
set -euxo pipefail
else
set -eo pipefail
set -euo pipefail
fi
IFS=$'\n\t'

kill_polybar() {
pkill polybar || true
@@ -13,60 +14,67 @@ kill_polybar() {
}

move_ws() {
i3-msg workspace 2
i3-msg move workspace to output left
WORKSPACE=$1
DIRECTION=$2
i3-msg workspace "$WORKSPACE"
i3-msg move workspace to output "$DIRECTION"
}

3_screen() {
1_screen
xrandr --output eDP-1 --auto --right-of DP-2 --output DP-2 --mode 3840x2160 --primary --output DP-1-2 --left-of DP-2 --rotate left
move_ws
set_wallpaper() {
SCREEN=$1
MODE=$2
IMAGE=$3
nitrogen --head="$SCREEN" --set-"$MODE" --save ~/pictures/wallpapers/"$IMAGE"
}

2_screen() {
1_screen
xrandr --output eDP-1 --auto --right-of DP-2 --output DP-2 --mode 3840x2160 --primary
move_ws
start_bar() {
MONITOR=$1
BAR=$2
polybar --reload "$BAR" </dev/null >"/var/tmp/polybar-$MONITOR.log" 2>&1 &
}

1_screen() {
work() {
xrandr \
--output eDP-1 --mode 1920x1080 --pos 5280x824 --rotate normal \
--output DP-1 --off \
--output HDMI-1 --off \
--output DP-2 --mode 3840x2160 --pos 1440x284 --rotate normal \
--output DP-1-1 --off \
--output DP-1-2 --mode 2560x1440 --pos 0x0 --rotate right \
--output DP-1-3 --off \
--output DP-2-1 --off \
--output DP-2-2 --off \
--output DP-2-3 --off
set_wallpaper 2 scaled IMG_20190901_161515-PANO.jpg
set_wallpaper 1 auto IMG_20190903_163002-EFFECTS.jpg
set_wallpaper 0 zoom-fill IMG_20190730_155936-PANO.jpg
move_ws 2 left
TRAY_POSITION=right start_bar DP-2 4k
start_bar eDP-1 1080p
}

laptop() {
xrandr --auto
set_wallparer 0 auto EFFECTS.jpg
TRAY_POSITION=right start_bar eDP-1 1080p
}

cmd_args() {
if [[ $# -ne 1 ]]; then
laptop
exit 0
fi
for i in "$@"; do
case $i in
-w | --work) work ;;
*) laptop ;;
esac
done
}

(
flock 200

[ -f ~/.dotfiles/Xresources ] && xrdb -merge -I"$HOME" ~/.dotfiles/Xresources
kill_polybar

outputs=$(polybar --list-monitors | cut -d"+" -f1 | sed "s/:\ /-/g")
tray_output=eDP1

for m in $(echo "$outputs" | cut -d"-" -f1); do
if [[ $m == "DP2" ]]; then
tray_output=$m
fi
done

${#outputs[@]}_screen

for m in $outputs; do
MONITOR=$(echo "$m" | cut -d"-" -f1)
TRAY_POSITION=none
if [[ $MONITOR == "$tray_output" ]]; then
TRAY_POSITION=right
fi
BAR=1080p
size=$(echo "$m" | cut -d"-" -f2 | cut -d"x" -f1)
if [[ $size -ge 3200 ]]; then
BAR=4k
fi

export TRAY_POSITION
export MONITOR
polybar --reload "$BAR" </dev/null >"/var/tmp/polybar-$m.log" 2>&1 200>&- &
disown
done

feh --bg-fill "$HOME"/pictures/wallpaper.jpg
cmd_args "$@"
) 200>/var/tmp/polybar-launch.lock

+ 5
- 5
swappy.sh View File

@@ -19,13 +19,13 @@ get_swap() {
Name) PROGNAME="$VALUE" ;;
VmSwap) SUM=$((SUM = ${VALUE% *})) ;;
esac
done <$FILE
[ $SUM -gt 0 ] &&
CMDLINE=$(cat /proc/$PID/cmdline) &&
printf "PID: %9d swapped: %11d KB (%s): [%s]\n" $PID $SUM "$PROGNAME" "$CMDLINE"
done <"$FILE"
[ "$SUM" -gt 0 ] &&
CMDLINE=$(cat /proc/"$PID"/cmdline) &&
printf "PID: %9d swapped: %11d KB (%s): [%s]\n" "$PID" "$SUM" "$PROGNAME" "$CMDLINE"
OVERALL=$((OVERALL + SUM))
done
printf "Total swapped memory: %14u KB\n" $OVERALL
printf "Total swapped memory: %14u KB\n" "$OVERALL"
}

get_swap | sort -r -k4 -n

+ 1
- 1
vpn View File

@@ -43,4 +43,4 @@ read -r OTP_PW
sudo openconnect \
--servercert=sha256:376185de3cbbeb2f66941d339092e989d6c03fe540f5ace84353e5fd6880215f \
--authgroup="LDAP" --protocol=nc https://"$URL"/dana-na/auth/url_default/welcome.cgi \
--user="$LDAP_USER" --passwd-on-stdin <<<"${LDAP_PW}${newline}${OTP_PW}" &
--user="$LDAP_USER" --passwd-on-stdin <<<"$LDAP_PW$newline$OTP_PW" &

Loading…
Cancel
Save