init commit
This commit is contained in:
11
sway/waybar/scripts/Cava.sh
Executable file
11
sway/waybar/scripts/Cava.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
is_cava_ServerExist=`ps -ef|grep -m 1 cava|grep -v "grep"|wc -l`
|
||||
if [ "$is_cava_ServerExist" = "0" ]; then
|
||||
echo "cava_server not found" > /dev/null 2>&1
|
||||
# exit;
|
||||
elif [ "$is_cava_ServerExist" = "1" ]; then
|
||||
killall cava
|
||||
fi
|
||||
|
||||
exec cava -p ~/.config/cava/config1 | sed -u 's/;//g;s/0/▁/g;s/1/▂/g;s/2/▃/g;s/3/▄/g;s/4/▅/g;s/5/▆/g;s/6/▇/g;s/7/█/g;'
|
3
sway/waybar/scripts/check_updates.sh
Executable file
3
sway/waybar/scripts/check_updates.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
i="$(checkupdates)"
|
||||
printf "%b%b" "$i" "${i:+\n}" |wc -l; echo "$i" |column -t #|tr '\n' '\r'
|
73
sway/waybar/scripts/keyhint-full.sh
Executable file
73
sway/waybar/scripts/keyhint-full.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
yad --title="Garuda Sway-WM keybindings:" --no-buttons --width=481 --height=361 --list --column-align=l --column="Keyboard Shortcuts" --column="Command Description" \
|
||||
"Esc" "Close this cheat-sheet" \
|
||||
"=" "modkey" \
|
||||
"+Return" "Start Terminal" \
|
||||
"+q" "Close focused app" \
|
||||
"+d" "Application menu (wofi)" \
|
||||
"+p" "Activities" \
|
||||
"+Shift+e" "Power menu" \
|
||||
"+F1" "Lock the system" \
|
||||
"+Shift+c" "Reload the config file" \
|
||||
"+h" "Focus left" \
|
||||
"+j" "Focus down" \
|
||||
"+k" "Focus up" \
|
||||
"+l" "Focus right" \
|
||||
"+Left" "Focus left" \
|
||||
"+Down" "Focus down" \
|
||||
"+Up" "Focus up" \
|
||||
"+Right" "Focus right" \
|
||||
"+Shift+h" "Move left" \
|
||||
"+Shift+j" "Move down" \
|
||||
"+Shift+k" "Move up" \
|
||||
"+Shift+l" "Move right" \
|
||||
"+Shift+Left" "Move left" \
|
||||
"+Shift+Down" "Move down" \
|
||||
"+Shift+Up" "Move up" \
|
||||
"+Shift+Right" "Move right" \
|
||||
"+b" "Split in horizontal orientation" \
|
||||
"+v" "Split in vertical orientation" \
|
||||
"+f" "Fullscreen toggle" \
|
||||
"+s" "Layout stacking" \
|
||||
"+w" "Layout tabbed" \
|
||||
"+e" "Layout toggle split" \
|
||||
"+Shift+Space" "Floating toggle" \
|
||||
"+Space" "Focus toggle" \
|
||||
"+a" "Focus parent" \
|
||||
"+Right_mouse_button" "Resize floating window" \
|
||||
"+Left_mouse_button" "Move floating window" \
|
||||
"+Shift+Minus" "Move scratchpad" \
|
||||
"+Minus" "Scratchpad cycle" \
|
||||
"+r" "Resize" \
|
||||
"+h" "Focus left" \
|
||||
"+j" "Focus down" \
|
||||
"+k" "Focus up" \
|
||||
"+l" "Focus right" \
|
||||
"+Left" "Focus left" \
|
||||
"+Down" "Focus down" \
|
||||
"+Up" "Focus up" \
|
||||
"+Right" "Focus right" \
|
||||
"+Return/Escape" "Return to default" \
|
||||
"+1" "Workspace number 1" \
|
||||
"+2" "Workspace number 2" \
|
||||
"+3" "Workspace number 3" \
|
||||
"+4" "Workspace number 4" \
|
||||
"+5" "Workspace number 5" \
|
||||
"+6" "Workspace number 6" \
|
||||
"+7" "workspace number 7" \
|
||||
"+8" "Workspace number 8" \
|
||||
"+9" "Workspace number 9" \
|
||||
"+0" "Workspace number 10" \
|
||||
"+Shift+1" "Move container to workspace number 1" \
|
||||
"+Shift+2" "Move container to workspace number 2" \
|
||||
"+Shift+3" "Move container to workspace number 3" \
|
||||
"+Shift+4" "Move container to workspace number 4" \
|
||||
"+Shift+5" "Move container to workspace number 5" \
|
||||
"+Shift+6" "Move container to workspace number 6" \
|
||||
"+Shift+7" "Move container to workspace number 7" \
|
||||
"+Shift+8" "Move container to workspace number 8" \
|
||||
"+Shift+9" "Move container to workspace number 9 " \
|
||||
"+Shift+0" "Move container to workspace number 10" \
|
||||
"Print" "Full screenshot" \
|
||||
"Shift+Print" "Screenshot with options" \
|
||||
"+n" "Launch Thunar" \
|
||||
"+o" "FireDragon"
|
2
sway/waybar/scripts/keyhint.sh
Executable file
2
sway/waybar/scripts/keyhint.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
yad --title="null keybindings:" --no-buttons --geometry=600x345-15-400 --list --column=key: --column=description: --column=command: "ESC" "close this app" "" "=" "modkey" "(set mod Mod4)" "+enter" "Terminal" "(termite)" "+d" "Application Menu" "(rofi)" "+o" "" "Open Broswer" "+n" "" "Open Files" "+q" "close focused app" "(kill)" "Print-key" "screenshot" "(grim)" "+Shift+p" "open keybinding helper" "full list"
|
2
sway/waybar/scripts/keyhint.sh.save
Executable file
2
sway/waybar/scripts/keyhint.sh.save
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
yad --title="null keybindings:" --no-buttons --geometry=600x345-15-400 --list --column=key: --column=description: --column=command: "ESC" "close this app" "" "=" "modkey" "(set mod Mod4)" "+enter" "Terminal" "(termite)" "+d" "Application Menu" "(rofi)" "+o" "" "Open Broswer" "+n" "" "Open Files" "+q" "close focused app" "(kill)" "[Shift]+Print-key" "screenshot" "(grim)" "+Shift+e" "power-menu" "(wofi)" "+Shift+p" "open keybinding helper" "full list"
|
109
sway/waybar/scripts/network_traffic.sh
Executable file
109
sway/waybar/scripts/network_traffic.sh
Executable file
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
# network_traffic.sh [-tPOLLING_INTERVAL] [NETWORK_INTERFACE...]
|
||||
|
||||
getopts t: __ && shift
|
||||
isecs=${OPTARG:-1}
|
||||
ifaces=($@)
|
||||
: ${rate_max:=1000000} # maximum transfer rate for {percent}, can be overridden setting the env var
|
||||
|
||||
# `snore` adapted from https://blog.dhampir.no/content/sleeping-without-a-subprocess-in-bash-and-how-to-sleep-forever
|
||||
# without MacOS workaround, TODO: with _snore_fd initialized separatedly, also i dont touch IFS so dont bother with it
|
||||
snore() {
|
||||
local IFS
|
||||
[[ -n "${_snore_fd:-}" ]] || { exec {_snore_fd}<> <(:); } 2>/dev/null
|
||||
read ${1:+-t "$1"} -u $_snore_fd || :
|
||||
}
|
||||
|
||||
human_readable() {
|
||||
local hrunits=( B K M G T P )
|
||||
local ndigits=${#1}
|
||||
local idxunit=$(( (2 + ndigits) / 3 - 1))
|
||||
local lentrim=$(( ndigits - (idxunit * 3 ) ))
|
||||
echo ${1::$lentrim}${hrunits[$idxunit]}
|
||||
}
|
||||
|
||||
exit_err() {
|
||||
printf '{"text": "⚠ %s", "tooltip": "%s", "class": "error"}\n' "$@"
|
||||
exit
|
||||
}
|
||||
|
||||
if test ${#ifaces[@]} -gt 0; then
|
||||
# sanity check the interface names
|
||||
for iface in ${ifaces[@]}; do
|
||||
test -h "/sys/class/net/${iface}" || exit_err "${iface}" "${iface} is not an existing network interface name"
|
||||
done
|
||||
else
|
||||
# default to all interfaces except `lo`
|
||||
ifaces=(/sys/class/net/*)
|
||||
ifaces=(${ifaces[@]##*/})
|
||||
ifaces=(${ifaces[@]//lo/})
|
||||
# TODO: check that filtering out `lo` is enough, else `^(eth|wlan|enp|wlp)` as suggested
|
||||
fi
|
||||
|
||||
# sanity check polling interval
|
||||
if test ${isecs} -lt 1; then
|
||||
exit_err "${isecs}" "${isecs} is not a valid polling interval"
|
||||
fi
|
||||
# NOTE: `snore` would take a decimal interval but bash arithmetic does not
|
||||
#if test $(echo "${isecs} >= 0.2" |bc) -eq 0; then
|
||||
# exit_err "${isecs}" "${isecs} is not a valid polling interval"
|
||||
#fi
|
||||
|
||||
# NOTE: `/proc/net/dev` format is:
|
||||
# interface:
|
||||
# RX bytes packets errs drop fifo frame compressed multicast
|
||||
# TX bytes packets errs drop fifo colls carrier compressed
|
||||
|
||||
# NOTE: array items are:
|
||||
# 0=rx_bytes 1=rx_packets 2=rx_errs 3=rx_drop
|
||||
# 4=tx_bytes 5=tx_packets 6=tx_errs 7=tx_drop
|
||||
for iface in ${ifaces[@]} aggregate; do
|
||||
declare -a traffic_prev_${iface} traffic_curr_${iface} traffic_delt_${iface}
|
||||
declare -n traffic_prev=traffic_prev_${iface}
|
||||
declare -n traffic_curr=traffic_curr_${iface}
|
||||
declare -n traffic_delt=traffic_delt_${iface}
|
||||
traffic_prev=( 0 0 0 0 0 0 0 0 )
|
||||
traffic_curr=( 0 0 0 0 0 0 0 0 )
|
||||
traffic_delt=( 0 0 0 0 0 0 0 0 )
|
||||
done
|
||||
|
||||
# TODO: rearrange the loop, do not show bogus on first iteration
|
||||
while snore ${isecs} ;do
|
||||
tooltip=""
|
||||
traffic_delt_aggregate=( 0 0 0 0 0 0 0 0 )
|
||||
|
||||
readarray -s2 proc_net_dev </proc/net/dev
|
||||
while read -a data; do
|
||||
iface=${data[0]%:}
|
||||
test "${ifaces[*]}" = "${ifaces[*]//${iface}/}" && continue
|
||||
declare -n traffic_prev=traffic_prev_${iface}
|
||||
declare -n traffic_curr=traffic_curr_${iface}
|
||||
declare -n traffic_delt=traffic_delt_${iface}
|
||||
traffic_curr=(${data[@]:1:4} ${data[@]:9:4})
|
||||
#FIXME: tooltip is delayed one iteration wrt main display (but why?)
|
||||
#printf -v tooltip_hr_rx '%4s⇣' $(human_readable ${traffic_delt[0]})
|
||||
#printf -v tooltip_hr_tx '%4s⇡' $(human_readable ${traffic_delt[4]})
|
||||
#tooltip="${tooltip:+${tooltip}\r}${iface}\t${tooltip_hr_rx}\t${tooltip_hr_tx}"
|
||||
for i in {0..7}; do
|
||||
(( traffic_delt[i] = ( traffic_curr[i] - traffic_prev[i] ) / isecs ))
|
||||
(( traffic_delt_aggregate[i] += traffic_delt[i] ))
|
||||
done
|
||||
traffic_prev=(${traffic_curr[@]})
|
||||
done <<<"${proc_net_dev[@]}"
|
||||
|
||||
printf '{"text": "%4s⇣ %4s⇡", "tooltip": "%s", "percentage": %d}\n' \
|
||||
$(human_readable ${traffic_delt_aggregate[0]}) \
|
||||
$(human_readable ${traffic_delt_aggregate[4]}) \
|
||||
"${tooltip}" \
|
||||
$(( ( traffic_delt_aggregate[0] + traffic_delt_aggregate[4] ) / rate_max ))
|
||||
#printf '{"text": "%5s⇣ %5s⇡", "alt": "%s", "tooltip": "%s", "class": "%s", "percentage": %d }\n' $(human_readable ${traffic_delt[0]}) $(human_readable ${traffic_delt[4]}) '_alt' '_tooltip' '_class' 0
|
||||
done
|
||||
|
||||
|
||||
# NOTE: in waybar config (do NOT use "interval"):
|
||||
# "custom/network_traffic": {
|
||||
# "exec": "~/.config/waybar/scripts/network_traffic.sh",
|
||||
# "return-type": "json",
|
||||
# "format": "Speed: {}", // optional
|
||||
# },
|
22
sway/waybar/scripts/swap.sh
Executable file
22
sway/waybar/scripts/swap.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the path to the config and style files
|
||||
config_file="${HOME}/.config/sway/waybar/config"
|
||||
config_background_file="${HOME}/.config/sway/waybar/config-background"
|
||||
style_file="${HOME}/.config/sway/waybar/style.css"
|
||||
style_background_file="${HOME}/.config/sway/waybar/style-background.css"
|
||||
|
||||
# Swap names of config files
|
||||
mv "${config_file}" "${config_file}.temp"
|
||||
mv "${config_background_file}" "${config_file}"
|
||||
mv "${config_file}.temp" "${config_background_file}"
|
||||
|
||||
# Swap names of style files
|
||||
mv "${style_file}" "${style_file}.temp"
|
||||
mv "${style_background_file}" "${style_file}"
|
||||
mv "${style_file}.temp" "${style_background_file}"
|
||||
|
||||
echo "File names swapped successfully!"
|
||||
|
||||
pkill waybar
|
||||
~/.config/sway/scripts/statusbar &
|
Reference in New Issue
Block a user