add useful and used scripts
This commit is contained in:
20
.local/bin/camtoggle
Executable file
20
.local/bin/camtoggle
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
#pkill -f /dev/video || mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --demuxer-lavf-format=v4l2 --geometry=-0-0 --autofit=30% --title="mpvfloat" --profile=low-latency --untimed /dev/video0
|
||||
|
||||
onecam() {
|
||||
mpv --no-osc --no-input-default-bindings --input-conf=/dev/null mpv --demuxer-lavf-format=v4l2 --geometry=-0-0 --autofit=30% --title="mpvfloat" --profile=low-latency --untimed $1
|
||||
}
|
||||
|
||||
#Get all possible cameras
|
||||
allposs=$(v4l2-ctl --list-devices | sed ':a;N;$!ba;s/):\n/):/g')
|
||||
cameras=$(echo "$allposs" | awk '/):/ {print $1}')
|
||||
|
||||
# If there's only one camera
|
||||
[ "$(echo "$cameras" | wc -l)" -lt 2 ] &&
|
||||
{ input=$(v4l2-ctl --list-devices | sed -n "/^$cameras/,/video*/p" | tail -n 1 | awk '{print $1}') ; onecam "$input"; exit ;}
|
||||
|
||||
chosen=$(echo "$cameras" | dmenu -i -p "Which camera ?")
|
||||
input=$(v4l2-ctl --list-devices | sed -n "/^$chosen/,/video*/p" | tail -n 1 | awk '{print $1}')
|
||||
|
||||
onecam "$input"
|
||||
80
.local/bin/displayselect
Executable file
80
.local/bin/displayselect
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A UI for detecting and selecting all displays. Probes xrandr for connected
|
||||
# displays and lets user select one to use. User may also select "manual
|
||||
# selection" which opens arandr.
|
||||
|
||||
twoscreen() { # If multi-monitor is selected and there are two screens.
|
||||
|
||||
mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
|
||||
# Mirror displays using native resolution of external display and a scaled
|
||||
# version for the internal display
|
||||
if [ "$mirror" = "yes" ]; then
|
||||
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
|
||||
internal=$(echo "$screens" | grep -v "$external")
|
||||
|
||||
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | tail -n 1 | awk '{print $1}')
|
||||
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | tail -n 1 | awk '{print $1}')
|
||||
|
||||
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
|
||||
res_ext_y=$(echo "$res_external" | sed 's/.*x//' | sed 's/i//')
|
||||
res_int_x=$(echo "$res_internal" | sed 's/x.*//')
|
||||
res_int_y=$(echo "$res_internal" | sed 's/.*x//' | sed 's/i//')
|
||||
|
||||
scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
|
||||
scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
|
||||
|
||||
xrandr --output "$external" --auto --scale 1.0x1.0 --output "$internal" --auto --same-as "$external" --scale "$scale_x"x"$scale_y"
|
||||
else
|
||||
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||
secondary=$(echo "$screens" | grep -v "$primary")
|
||||
direction=$(printf "left-of\\nright-of\\nabove\\nbelow" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction" "$primary" --auto --scale 1.0x1.0
|
||||
fi
|
||||
}
|
||||
|
||||
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
|
||||
direction=$(printf "left-of\\nright-of\\nabove\\nbelow" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
|
||||
direction2=$(printf "left-of\\nright-of\\nabove\\nbelow" | dmenu -i -p "What side of $secondary should $tertiary be on?")
|
||||
xrandr --output "$primary" --auto --output "$secondary" --"$direction" "$primary" --auto --output "$tertiary" --"$direction2" "$primary" --auto
|
||||
}
|
||||
|
||||
multimon() { # Multi-monitor handler.
|
||||
case "$(echo "$screens" | wc -l)" in
|
||||
2) twoscreen ;;
|
||||
*) morescreen ;;
|
||||
esac ;}
|
||||
|
||||
onescreen() { # If only one output available or chosen.
|
||||
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ')
|
||||
}
|
||||
|
||||
postrun() { # Stuff to run to clean up.
|
||||
setbg # Fix background if screen size/arangement has changed.
|
||||
remaps # Re-remap keys if keyboard added (for laptop bases)
|
||||
{ killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
|
||||
}
|
||||
|
||||
# Get all possible displays
|
||||
allposs=$(xrandr -q | grep "connected")
|
||||
|
||||
# Get all connected screens.
|
||||
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
|
||||
|
||||
# If there's only one screen
|
||||
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
|
||||
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;}
|
||||
|
||||
# Get user choice including multi-monitor and manual selection:
|
||||
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
|
||||
case "$chosen" in
|
||||
"manual selection") arandr ; exit ;;
|
||||
"multi-monitor") multimon ;;
|
||||
*) onescreen "$chosen" ;;
|
||||
esac
|
||||
|
||||
postrun
|
||||
1
.local/bin/doas_askpass
Submodule
1
.local/bin/doas_askpass
Submodule
Submodule .local/bin/doas_askpass added at db7da6746c
105
.local/bin/mounter
Executable file
105
.local/bin/mounter
Executable file
@@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Mounts Android Phones and USB drives (encrypted or not). This script will
|
||||
# replace the older `dmenumount` which had extra steps and couldn't handle
|
||||
# encrypted drives.
|
||||
# TODO: Remove already mounted Android phones from prompt.
|
||||
# TODO: Try decrypt for drives in crtypttab
|
||||
# TODO: Add some support for connecting iPhones (although they are annoying).
|
||||
|
||||
set -e
|
||||
|
||||
# Check for phones.
|
||||
phones="$(simple-mtpfs -l 2>/dev/null | sed "s/^/📱/")"
|
||||
# Check for drives.
|
||||
lsblkoutput="$(lsblk -rpo "uuid,name,type,size,label,mountpoint,fstype")"
|
||||
# Get all LUKS drives
|
||||
allluks="$(echo "$lsblkoutput" | grep crypto_LUKS)" || true
|
||||
# Get a list of the LUKS drive UUIDs already decrypted.
|
||||
decrypted="$(find /dev/disk/by-id/dm-uuid-CRYPT-LUKS2-* | sed "s|.*LUKS2-||;s|-.*||")" || true
|
||||
# Functioning for formatting drives correctly for dmenu:
|
||||
filter() { sed "s/ /:/g" | awk -F':' '$7==""{printf "%s%s (%s) %s\n",$1,$3,$5,$6}' ; }
|
||||
|
||||
# Get only LUKS drives that are not decrypted.
|
||||
IFS='
|
||||
'
|
||||
unopenedluks="$(for drive in $allluks; do
|
||||
uuid="${drive%% *}"
|
||||
uuid="${uuid//-}" # This is a bashism.
|
||||
for open in $decrypted; do
|
||||
[ "$uuid" = "$open" ] && break 1
|
||||
done && continue 1
|
||||
echo "🔒 $drive"
|
||||
done | filter)"
|
||||
|
||||
# Get all normal, non-encrypted or decrypted partitions that are not mounted.
|
||||
normalparts="$(echo "$lsblkoutput"| grep -v crypto_LUKS | grep 'part\|rom\|crypt' | sed "s/^/💾 /" | filter )"
|
||||
|
||||
# Add all to one variable. If no mountable drives found, exit.
|
||||
alldrives="$(echo "$phones
|
||||
$unopenedluks
|
||||
$normalparts" | sed "/^$/d;s/ *$//")"
|
||||
test -n "$alldrives"
|
||||
|
||||
# Feed all found drives to dmenu and get user choice.
|
||||
chosen="$(echo "$alldrives" | dmenu -p "Mount which drive?" -i)"
|
||||
|
||||
# Function for prompting user for a mountpoint.
|
||||
getmount(){
|
||||
mp="$(find /mnt /media /mount /home -maxdepth 1 -type d 2>/dev/null | dmenu -i -p "Mount this drive where?")"
|
||||
test -n "$mp"
|
||||
if [ ! -d "$mp" ]; then
|
||||
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?")
|
||||
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
||||
fi
|
||||
}
|
||||
|
||||
attemptmount(){
|
||||
# Attempt to mount without a mountpoint, to see if drive is in fstab.
|
||||
sudo -A mount "$chosen" || return 1
|
||||
notify-send "💾Drive Mounted." "$chosen mounted."
|
||||
exit
|
||||
}
|
||||
|
||||
case "$chosen" in
|
||||
💾*)
|
||||
chosen="${chosen%% *}"
|
||||
chosen="${chosen:1}" # This is a bashism.
|
||||
attemptmount || getmount
|
||||
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
||||
case "$partitiontype" in
|
||||
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
|
||||
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
|
||||
esac
|
||||
# sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)"
|
||||
notify-send "💾Drive Mounted." "$chosen mounted to $mp."
|
||||
;;
|
||||
|
||||
🔒*)
|
||||
chosen="${chosen%% *}"
|
||||
chosen="${chosen:1}" # This is a bashism.
|
||||
# Number the drive.
|
||||
while true; do
|
||||
[ -f "/dev/mapper/usb$num" ] || break
|
||||
num="$(printf "%02d" "$((num +1))")"
|
||||
done
|
||||
|
||||
# Decrypt in a terminal window
|
||||
${TERMINAL:-st} -n floatterm -g 60x1 -e sudo cryptsetup open "$chosen" "usb$num"
|
||||
# Check if now decrypted.
|
||||
test -b "/dev/mapper/usb$num"
|
||||
|
||||
attemptmount || getmount
|
||||
sudo -A mount "/dev/mapper/usb$num" "$mp" -o uid="$(id -u)",gid="$(id -g)"
|
||||
notify-send "🔓Decrypted drive Mounted." "$chosen decrypted and mounted to $mp."
|
||||
;;
|
||||
|
||||
📱*)
|
||||
notify-send "❗Note" "Remember to allow file access on your phone now."
|
||||
getmount
|
||||
chosen="${chosen%%:*}"
|
||||
chosen="${chosen:1}" # This is a bashism.
|
||||
sudo -A simple-mtpfs -o allow_other --device "$chosen" "$mp"
|
||||
notify-send "🤖 Android Mounted." "Android device mounted to $mp."
|
||||
;;
|
||||
esac
|
||||
10
.local/bin/pauseallmpv
Executable file
10
.local/bin/pauseallmpv
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# You might notice all mpv commands are aliased to have this input-ipc-server
|
||||
# thing. That's just for this particular command, which allows us to pause
|
||||
# every single one of them with one command! This is bound to super + shift + p
|
||||
# (with other things) by default and is used in some other places.
|
||||
|
||||
for i in $(ls /tmp/mpvSockets/*); do
|
||||
echo '{ "command": ["set_property", "pause", true] }' | socat - "$i";
|
||||
done
|
||||
14
.local/bin/queueandnotify
Executable file
14
.local/bin/queueandnotify
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Podboat sucks. This script replaces it.
|
||||
# It reads the newsboat queue, queuing downloads with taskspooler.
|
||||
# It also removes the junk from extentions.
|
||||
queuefile="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/queue"
|
||||
|
||||
while read -r line; do
|
||||
[ -z "$line" ] && continue
|
||||
url="$(echo "$line" | awk '{print $1}')"
|
||||
qndl "$url" "curl -LO"
|
||||
done < "$queuefile"
|
||||
|
||||
echo > "$queuefile"
|
||||
14
.local/bin/remaps
Executable file
14
.local/bin/remaps
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script is called on startup to remap keys.
|
||||
# Increase key speed via a rate change
|
||||
xset r rate 300 50
|
||||
# Map the caps lock key to super...
|
||||
setxkbmap -option caps:super
|
||||
# But when it is pressed only once, treat it as escape.
|
||||
killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape'
|
||||
# Map the menu button to right super as well.
|
||||
xmodmap -e 'keycode 135 = Super_R'
|
||||
|
||||
# Map the multimedia button
|
||||
xmodmap -e 'keycode 179 = XF86AudioMedia NoSymbol XF86AudioMedia'
|
||||
10
.local/bin/rssadd
Executable file
10
.local/bin/rssadd
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null &&
|
||||
notify-send "That doesn't look like a full URL." && exit
|
||||
RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
|
||||
if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then
|
||||
notify-send "You already have this RSS feed."
|
||||
else
|
||||
echo "$1" >> "$RSSFILE" && notify-send "RSS feed added."
|
||||
fi
|
||||
20
.local/bin/setbg
Executable file
20
.local/bin/setbg
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script does the following:
|
||||
# Run by itself, set the wallpaper (at X start).
|
||||
# If given a file, set that as the new wallpaper.
|
||||
# If given a directory, choose random file in it.
|
||||
# If wal is installed, also generates a colorscheme.
|
||||
|
||||
# Location of link to wallpaper link.
|
||||
bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
|
||||
|
||||
[ -f "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..."
|
||||
|
||||
[ -d "$1" ] && ln -sf "$(find "$(readlink -f "$1")" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen."
|
||||
|
||||
# If pywal is installed, use it.
|
||||
wal -i "$(readlink -f "$bgloc")" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1
|
||||
|
||||
pidof dwm >/dev/null && xdotool key super+F12
|
||||
xwallpaper --zoom "$bgloc"
|
||||
31
.local/bin/shortcuts
Executable file
31
.local/bin/shortcuts
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Output locations. Unactivated progs should go to /dev/null.
|
||||
shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
|
||||
zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
|
||||
ranger_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/ranger/shortcuts.conf"
|
||||
qute_shortcuts="/dev/null"
|
||||
fish_shortcuts="/dev/null"
|
||||
vifm_shortcuts="/dev/null"
|
||||
|
||||
# Remove, prepare files
|
||||
rm -f "$ranger_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" 2>/dev/null
|
||||
printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
|
||||
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
|
||||
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
|
||||
|
||||
# Format the `directories` file in the correct syntax and sent it to all three configs.
|
||||
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
||||
printf(\"%s=\42cd %s && ls -a\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
||||
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
||||
printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
||||
printf(\"map g%s :cd %s<CR>\nmap t%s <tab>:cd %s<CR><tab>\nmap M%s <tab>:cd %s<CR><tab>:mo<CR>\nmap Y%s <tab>:cd %s<CR><tab>:co<CR> \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ;
|
||||
printf(\"config.bind(';%s', \42set downloads.location.directory %s ;; hint links download\42) \n\",\$1,\$2) >> \"$qute_shortcuts\" ;
|
||||
printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs"
|
||||
|
||||
# Format the `files` file in the correct syntax and sent it to both configs.
|
||||
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
||||
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
||||
printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
||||
printf(\"map %s :e %s<CR> \n\",\$1,\$2) >> \"$vifm_shortcuts\" ;
|
||||
printf(\"map %s shell \$EDITOR %s \n\",\$1,\$2) >> \"$ranger_shortcuts\" }" "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-files"
|
||||
39
.local/bin/statusbar/sb-battery
Executable file
39
.local/bin/statusbar/sb-battery
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Prints all batteries, their percentage remaining and an emoji corresponding
|
||||
# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.).
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) notify-send "🔋 Battery module" "🔋: discharging
|
||||
🛑: not charging
|
||||
♻: stagnant charge
|
||||
🔌: charging
|
||||
⚡: charged
|
||||
- Scroll to change adjust xbacklight." ;;
|
||||
4) xbacklight -inc 10 ;;
|
||||
5) xbacklight -dec 10 ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
# acpi alternative
|
||||
acpi | sed "s/Battery [0-9]: //;s/[Dd]ischarging, /🔋/;s/[Nn]ot charging, /🛑/;s/[Cc]harging, /🔌/;s/[Uu]nknown, /♻️/;s/[Ff]ull, /⚡/;s/ \(remaining\|until charged\)//"; exit
|
||||
done | sed 's/ *$//'
|
||||
|
||||
# Loop through all attached batteries and format the info
|
||||
# for battery in /sys/class/power_supply/BAT?*; do
|
||||
# # If non-first battery, print a space separator.
|
||||
# [ -n "${capacity+x}" ] && printf " "
|
||||
# # Sets up the status and capacity
|
||||
# case "$(cat "$battery/status")" in
|
||||
# "Full") status="⚡" ;;
|
||||
# "Discharging") status="🔋" ;;
|
||||
# "Charging") status="🔌" ;;
|
||||
# "Not charging") status="🛑" ;;
|
||||
# "Unknown") status="♻️" ;;
|
||||
# esac
|
||||
# capacity=$(cat "$battery/capacity")
|
||||
# # Will make a warn variable if discharging and low
|
||||
# [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
|
||||
# # Prints the info
|
||||
# printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
|
||||
# done && exit 0
|
||||
29
.local/bin/statusbar/sb-clock
Executable file
29
.local/bin/statusbar/sb-clock
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
clock=$(date '+%I')
|
||||
|
||||
case "$clock" in
|
||||
"00") icon="🕛" ;;
|
||||
"01") icon="🕐" ;;
|
||||
"02") icon="🕑" ;;
|
||||
"03") icon="🕒" ;;
|
||||
"04") icon="🕓" ;;
|
||||
"05") icon="🕔" ;;
|
||||
"06") icon="🕕" ;;
|
||||
"07") icon="🕖" ;;
|
||||
"08") icon="🕗" ;;
|
||||
"09") icon="🕘" ;;
|
||||
"10") icon="🕙" ;;
|
||||
"11") icon="🕚" ;;
|
||||
"12") icon="🕛" ;;
|
||||
esac
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "This Month" "$(cal -m --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;;
|
||||
2) setsid -f "$TERMINAL" -e calcurse ;;
|
||||
3) notify-send "📅 Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
|
||||
- Middle click opens calcurse if installed" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
date "+%d %b %Y (%a) $icon%H:%M"
|
||||
12
.local/bin/statusbar/sb-cpu
Executable file
12
.local/bin/statusbar/sb-cpu
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "🖥 CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)\\n(100% per core)" ;;
|
||||
2) setsid -f "$TERMINAL" -e htop ;;
|
||||
3) notify-send "🖥 CPU module " "\- Shows CPU temperature.
|
||||
- Click to show intensive processes.
|
||||
- Middle click to open htop." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
sensors | awk '/Core 0/ {print "🌡" $3}'
|
||||
44
.local/bin/statusbar/sb-cpubars
Executable file
44
.local/bin/statusbar/sb-cpubars
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Module showing CPU load as a changing bars.
|
||||
# Just like in polybar.
|
||||
# Each bar represents amount of load on one core since
|
||||
# last run.
|
||||
|
||||
# Cache in tmpfs to improve speed and reduce SSD load
|
||||
cache=/tmp/cpubarscache
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
2) setsid -f "$TERMINAL" -e htop ;;
|
||||
3) notify-send "🪨 CPU load module" "Each bar represents
|
||||
one CPU core";;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
# id total idle
|
||||
stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat)
|
||||
[ ! -f $cache ] && echo "$stats" > "$cache"
|
||||
old=$(cat "$cache")
|
||||
printf "🪨"
|
||||
echo "$stats" | while read -r row; do
|
||||
id=${row%% *}
|
||||
rest=${row#* }
|
||||
total=${rest%% *}
|
||||
idle=${rest##* }
|
||||
|
||||
case "$(echo "$old" | awk '{if ($1 == id)
|
||||
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
|
||||
id="$id" total="$total" idle="$idle")" in
|
||||
|
||||
"0") printf "▁";;
|
||||
"1") printf "▂";;
|
||||
"2") printf "▃";;
|
||||
"3") printf "▄";;
|
||||
"4") printf "▅";;
|
||||
"5") printf "▆";;
|
||||
"6") printf "▇";;
|
||||
"7") printf "█";;
|
||||
"8") printf "█";;
|
||||
esac
|
||||
done; printf "\\n"
|
||||
echo "$stats" > "$cache"
|
||||
23
.local/bin/statusbar/sb-disk
Executable file
23
.local/bin/statusbar/sb-disk
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Status bar module for disk space
|
||||
# $1 should be drive mountpoint, otherwise assumed /.
|
||||
|
||||
location=${1:-/}
|
||||
|
||||
[ -d "$location" ] || exit
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
|
||||
3) notify-send "💽 Disk module" "\- Shows used hard drive space.
|
||||
- Click to show all disk info." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
case "$location" in
|
||||
"/home"* ) icon="🏠" ;;
|
||||
"/mnt"* ) icon="💾" ;;
|
||||
*) icon="🖥";;
|
||||
esac
|
||||
|
||||
printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"
|
||||
35
.local/bin/statusbar/sb-forecast
Executable file
35
.local/bin/statusbar/sb-forecast
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Displays todays precipication chance (☔) and daily low (🥶) and high (🌞).
|
||||
# Usually intended for the statusbar.
|
||||
|
||||
# If we have internet, get a weather report from wttr.in and store it locally.
|
||||
# You could set up a shell alias to view the full file in a pager in the
|
||||
# terminal if desired. This function will only be run once a day when needed.
|
||||
weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport"
|
||||
getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;}
|
||||
|
||||
# Some very particular and terse stream manipulation. We get the maximum
|
||||
# precipitation chance and the daily high and low from the downloaded file and
|
||||
# display them with coresponding emojis.
|
||||
showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" |
|
||||
grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔/g;1q" | tr -d '\n')"
|
||||
sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶" $1 "°","🌞" $2 "°"}' ;}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;;
|
||||
2) getforecast && showweather ;;
|
||||
3) notify-send "🌈 Weather module" "\- Left click for full forecast.
|
||||
- Middle click to update forecast.
|
||||
☔: Chance of rain/snow
|
||||
🥶: Daily low
|
||||
🌞: Daily high" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
# The test if our forcecast is updated to the day. If it isn't download a new
|
||||
# weather report from wttr.in with the above function.
|
||||
[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
||||
getforecast
|
||||
|
||||
showweather
|
||||
24
.local/bin/statusbar/sb-internet
Executable file
24
.local/bin/statusbar/sb-internet
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Show wifi 📶 and percent strength or 📡 if none.
|
||||
# Show 🌐 if connected to ethernet or ❎ if none.
|
||||
# Show 🔒 if a vpn connection is active
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
|
||||
3) notify-send "🌐 Internet module" "\- Click to connect
|
||||
📡: no wifi connection
|
||||
📶: wifi connection with quality
|
||||
❎: no ethernet
|
||||
🌐: ethernet working
|
||||
🔒: vpn is active
|
||||
" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
|
||||
down) wifiicon="📡 " ;;
|
||||
up) wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;;
|
||||
esac
|
||||
|
||||
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)"
|
||||
10
.local/bin/statusbar/sb-iplocate
Executable file
10
.local/bin/statusbar/sb-iplocate
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Gets your public ip address checks which country you are in and
|
||||
# displays that information in the statusbar
|
||||
#
|
||||
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
|
||||
|
||||
ifinstalled "geoip" || exit
|
||||
addr="$(curl ifconfig.me 2>/dev/null)" || exit
|
||||
grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"
|
||||
16
.local/bin/statusbar/sb-kbselect
Executable file
16
.local/bin/statusbar/sb-kbselect
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# works on any init system
|
||||
# requirements: dmenu, xorg-setxkbmap
|
||||
kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)"
|
||||
kb="$(echo "$kb_choice" | awk '{print $3}')"
|
||||
setxkbmap "$kb"
|
||||
pkill -RTMIN+30 "${STATUSBAR:-i3blocks}";;
|
||||
3) notify-send "⌨ Keyboard/language module" "$(printf "%s" "\- Current layout: $(setxkbmap -query | grep -oP 'layout:\s*\K\w+')")
|
||||
- Left click to change keyboard.";;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
echo "$kb"
|
||||
12
.local/bin/statusbar/sb-memory
Executable file
12
.local/bin/statusbar/sb-memory
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
|
||||
2) setsid -f "$TERMINAL" -e htop ;;
|
||||
3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
|
||||
- Click to show memory hogs.
|
||||
- Middle click to open htop." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
|
||||
37
.local/bin/statusbar/sb-moonphase
Executable file
37
.local/bin/statusbar/sb-moonphase
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Shows the current moon phase.
|
||||
|
||||
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
|
||||
|
||||
[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
||||
{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
|
||||
|
||||
icon="$(cat "$moonfile")"
|
||||
|
||||
case "$icon" in
|
||||
🌑) name="New" ;;
|
||||
🌒) name="Waxing Crescent" ;;
|
||||
🌓) name="First Quarter" ;;
|
||||
🌔) name="Waxing Gibbous" ;;
|
||||
🌕) name="Full" ;;
|
||||
🌖) name="Waning Gibbous" ;;
|
||||
🌗) name="Last Quarter" ;;
|
||||
🌘) name="Waning Crescent" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
|
||||
echo "${icon-?}"
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) notify-send "🌜 Moon phase module" "Displays current moon phase.
|
||||
- 🌑: New
|
||||
- 🌒: Waxing Crescent
|
||||
- 🌓: First Quarter
|
||||
- 🌔: Waxing Gibbous
|
||||
- 🌕: Full
|
||||
- 🌖: Waning Gibbous
|
||||
- 🌗: Last Quarter
|
||||
- 🌘: Waning Crescent" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
8
.local/bin/statusbar/sb-mpdup
Executable file
8
.local/bin/statusbar/sb-mpdup
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This loop will update the mpd statusbar module whenever a command changes the
|
||||
# music player's status. mpd must be running on X's start for this to work.
|
||||
|
||||
while : ; do
|
||||
mpc idle >/dev/null && kill -45 "$(pidof "${STATUSBAR:-i3blocks}")" || break
|
||||
done
|
||||
19
.local/bin/statusbar/sb-music
Executable file
19
.local/bin/statusbar/sb-music
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -| awk '{ if($0>0) print "🎶 " $0}';}
|
||||
|
||||
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
|
||||
2) mpc toggle | filter ;; # right click, pause/unpause
|
||||
3) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing.
|
||||
- ⏸ when paused.
|
||||
- Left click opens ncmpcpp.
|
||||
- Middle click pauses.
|
||||
- Scroll changes track.";; # right click, pause/unpause
|
||||
4) mpc prev | filter ;; # scroll up, previous
|
||||
5) mpc next | filter ;; # scroll down, next
|
||||
6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
*) mpc status | filter ;;
|
||||
esac
|
||||
29
.local/bin/statusbar/sb-nettraf
Executable file
29
.local/bin/statusbar/sb-nettraf
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Module showing network traffic. Shows how much data has been received (RX) or
|
||||
# transmitted (TX) since the previous time this script ran. So if run every
|
||||
# second, gives network traffic per second.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e bmon ;;
|
||||
3) notify-send "🌐 Network traffic module" "🔻: Traffic received
|
||||
🔺: Traffic transmitted" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
update() {
|
||||
sum=0
|
||||
for arg; do
|
||||
read -r i < "$arg"
|
||||
sum=$(( sum + i ))
|
||||
done
|
||||
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
|
||||
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
||||
printf %d\\n "$sum" > "$cache"
|
||||
printf %d\\n $(( sum - old ))
|
||||
}
|
||||
|
||||
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
||||
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
|
||||
|
||||
printf "🔻%4sB 🔺%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
|
||||
17
.local/bin/statusbar/sb-news
Executable file
17
.local/bin/statusbar/sb-news
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Displays number of unread news items and an loading icon if updating.
|
||||
# When clicked, brings up `newsboat`.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid "$TERMINAL" -e newsboat ;;
|
||||
2) setsid -f newsup >/dev/null exit ;;
|
||||
3) notify-send "📰 News module" "\- Shows unread news items
|
||||
- Shows 🔃 if updating with \`newsup\`
|
||||
- Left click opens newsboat
|
||||
- Middle click syncs RSS feeds
|
||||
<b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "📰" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)"
|
||||
29
.local/bin/statusbar/sb-pacpackages
Executable file
29
.local/bin/statusbar/sb-pacpackages
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Displays number of upgradeable packages.
|
||||
# For this to work, have a `pacman -Sy` command run in the background as a
|
||||
# cronjob every so often as root. This script will then read those packages.
|
||||
# When clicked, it will run an upgrade via pacman.
|
||||
#
|
||||
# Add the following text as a file in /usr/share/libalpm/hooks/statusbar.hook:
|
||||
#
|
||||
# [Trigger]
|
||||
# Operation = Upgrade
|
||||
# Type = Package
|
||||
# Target = *
|
||||
#
|
||||
# [Action]
|
||||
# Description = Updating statusbar...
|
||||
# When = PostTransaction
|
||||
# Exec = /usr/bin/pkill -RTMIN+8 dwmblocks # Or i3blocks if using i3.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e sb-popupgrade ;;
|
||||
2) notify-send "$(/usr/bin/pacman -Qu)" ;;
|
||||
3) notify-send "🎁 Upgrade module" "📦: number of upgradable packages
|
||||
- Left click to upgrade packages
|
||||
- Middle click to show upgradable packages" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/📦/;s/^📦0$//g"
|
||||
10
.local/bin/statusbar/sb-popupgrade
Executable file
10
.local/bin/statusbar/sb-popupgrade
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
printf "Beginning upgrade.\\n"
|
||||
|
||||
yay -Syu
|
||||
|
||||
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
|
||||
read -r _
|
||||
|
||||
i3 restart
|
||||
38
.local/bin/statusbar/sb-price
Executable file
38
.local/bin/statusbar/sb-price
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Usage:
|
||||
# price <url> <Name of currency> <icon>
|
||||
# price bat "Basic Attention Token" 🦁
|
||||
# When the name of the currency is multi-word, put it in quotes.
|
||||
|
||||
[ -z "$3" ] && exit 1
|
||||
interval="@14d" # History contained in chart preceded by '@' (7d = 7 days)
|
||||
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
|
||||
pricefile="$dir/$1"
|
||||
chartfile="$dir/$1-chart"
|
||||
|
||||
updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 &&
|
||||
curl -s "rate.sx/1$1" > "$pricefile" &&
|
||||
curl -s "rate.sx/$1$interval" > "$chartfile" ;}
|
||||
|
||||
[ -d "$dir" ] || mkdir -p "$dir"
|
||||
|
||||
[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
|
||||
updateprice "$1"
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid "$TERMINAL" -e less -Srf "$chartfile" ;;
|
||||
2) notify-send -u low "$3 Updating..." "Updating $2 price..."
|
||||
updateprice "$1" && notify-send "$3 Update complete." "$2 price is now
|
||||
\$$(cat "$pricefile")" ;;
|
||||
3) uptime="$(date -d "$(stat -c %x "$pricefile")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
|
||||
notify-send "$3 $2 module" "\- <b>Exact price: \$$(cat "$pricefile")</b>
|
||||
- Left click for chart of changes.
|
||||
- Middle click to update.
|
||||
- Shows 🔃 if updating prices.
|
||||
- <b>Last updated:
|
||||
$uptime</b>" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
printf "$3$%0.2f" "$(cat "$pricefile")"
|
||||
20
.local/bin/statusbar/sb-tasks
Executable file
20
.local/bin/statusbar/sb-tasks
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Originally by Andr3as07 <https://github.com/Andr3as07>
|
||||
# Some changes by Luke
|
||||
# Rebuild by Tenyun
|
||||
|
||||
# This block displays the number running background tasks. Requires tsp.
|
||||
|
||||
num=$(tsp -l | awk -v numr=0 -v numq=0 '{if (/running/)numr++; if (/queued/)numq++} END{print numr+numq"("numq")"}')
|
||||
|
||||
# Handle mouse clicks
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e tsp -l ;;
|
||||
3) notify-send "Tasks module" "🤖: number of running/queued background tasks
|
||||
- Left click opens tsp" ;; # Right click
|
||||
2) $EDITOR "$0" ;; # Middle click
|
||||
esac
|
||||
|
||||
[ "$num" != "0(0)" ] &&
|
||||
echo "🤖$num"
|
||||
27
.local/bin/statusbar/sb-torrent
Executable file
27
.local/bin/statusbar/sb-torrent
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
transmission-remote -l | grep % |
|
||||
sed " # The letters are for sorting and will not appear.
|
||||
s/.*Stopped.*/A 🛑/;
|
||||
s/.*Seeding.*/Z 🌱/;
|
||||
s/.*100%.*/N ✅/;
|
||||
s/.*Idle.*/B 🕰️/;
|
||||
s/.*Uploading.*/L ⬆️/;
|
||||
s/.*%.*/M ⬇️/" |
|
||||
sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' -
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e tremc ;;
|
||||
2) td-toggle ;;
|
||||
3) notify-send "🌱 Torrent module" "\- Left click to open tremc.
|
||||
- Middle click to toggle transmission.
|
||||
- Shift click to edit script.
|
||||
Module shows number of torrents:
|
||||
🛑: paused
|
||||
🕰: idle (seeds needed)
|
||||
🔼: uploading (unfinished)
|
||||
🔽: downloading
|
||||
✅: done
|
||||
🌱: done and seeding" ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
28
.local/bin/statusbar/sb-volume
Executable file
28
.local/bin/statusbar/sb-volume
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Prints the current volume or 🔇 if muted.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e pulsemixer ;;
|
||||
2) pamixer -t ;;
|
||||
4) pamixer --allow-boost -i 1 ;;
|
||||
5) pamixer --allow-boost -d 1 ;;
|
||||
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
|
||||
- Middle click to mute.
|
||||
- Scroll to change." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
[ $(pamixer --get-mute) = true ] && echo 🔇 && exit
|
||||
|
||||
vol="$(pamixer --get-volume)"
|
||||
|
||||
if [ "$vol" -gt "70" ]; then
|
||||
icon="🔊"
|
||||
elif [ "$vol" -lt "30" ]; then
|
||||
icon="🔈"
|
||||
else
|
||||
icon="🔉"
|
||||
fi
|
||||
|
||||
echo "$icon$vol%"
|
||||
19
.local/bin/sysact
Executable file
19
.local/bin/sysact
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A dmenu wrapper script for system functions.
|
||||
|
||||
# For non-systemd init systems.
|
||||
case "$(readlink -f /sbin/init)" in
|
||||
*runit*) hib="doas_askpass zzz" ;;
|
||||
*openrc*) hib="loginctl suspend" ; reb="loginctl reboot"; shut="loginctl poweroff";;
|
||||
esac
|
||||
|
||||
cmds="\
|
||||
🔒 lock slock
|
||||
🐻 hibernate ${hib:-doas_askpass systemctl suspend}
|
||||
🔃 reboot ${reb:-doas_askpass reboot}
|
||||
🖥 shutdown ${shut:-doas_askpass shutdown -h now}"
|
||||
|
||||
choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1
|
||||
|
||||
`echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-`
|
||||
12
.local/bin/td-toggle
Executable file
12
.local/bin/td-toggle
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# If transmission-daemon is running, will ask to kill, else will ask to start.
|
||||
|
||||
if pidof transmission-daemon >/dev/null ;
|
||||
then
|
||||
[ "$(printf "No\\nYes" | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-daemon && notify-send "transmission-daemon disabled."
|
||||
else
|
||||
ifinstalled transmission-cli || exit
|
||||
[ "$(printf "No\\nYes" | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon enabled."
|
||||
fi
|
||||
sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
||||
28
.local/bin/unmounter
Executable file
28
.local/bin/unmounter
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Unmount USB drives or Android phones. Replaces the older `dmenuumount`. Fewer
|
||||
# prompt and also de-decrypts LUKS drives that are unmounted.
|
||||
|
||||
set -e
|
||||
|
||||
mounteddroids="$(grep simple-mtpfs /etc/mtab | awk '{print "📱" $2}')"
|
||||
lsblkoutput="$(lsblk -nrpo "name,type,size,mountpoint")"
|
||||
mounteddrives="$(echo "$lsblkoutput" | awk '($2=="part"||$2="crypt")&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "💾%s (%s)\n",$4,$3}')"
|
||||
|
||||
allunmountable="$(echo "$mounteddroids
|
||||
$mounteddrives" | sed "/^$/d;s/ *$//")"
|
||||
test -n "$allunmountable"
|
||||
|
||||
chosen="$(echo "$allunmountable" | dmenu -i -p "Unmount which drive?")"
|
||||
chosen="${chosen%% *}"
|
||||
test -n "$chosen"
|
||||
|
||||
sudo -A umount -l "/${chosen#*/}"
|
||||
notify-send "Device unmounted." "$chosen has been unmounted."
|
||||
|
||||
# Close the chosen drive if decrypted.
|
||||
cryptid="$(echo "$lsblkoutput" | grep "/${chosen#*/}$")"
|
||||
cryptid="${cryptid%% *}"
|
||||
test -b /dev/mapper/"${cryptid##*/}"
|
||||
sudo -A cryptsetup close "$cryptid"
|
||||
notify-send "🔒Device dencryption closed." "Drive is now securely locked again."
|
||||
1
.local/src/dmenu
Submodule
1
.local/src/dmenu
Submodule
Submodule .local/src/dmenu added at 3a6bc67fbd
1
.local/src/st
Submodule
1
.local/src/st
Submodule
Submodule .local/src/st added at 13b3c631be
Reference in New Issue
Block a user