updated scripts to pass shellcheck, mostly

This commit is contained in:
Solomon Laing 2023-02-14 12:31:39 +10:30
parent cf18461c24
commit 7bc48e0a0d
47 changed files with 327 additions and 431 deletions

View File

@ -26,7 +26,7 @@ return {
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
opts = { opts = {
-- Animation style (see below for details) -- Animation style (see below for details)
stages = "fade_in_slide_out", stages = "static",
-- Render function for notifications. See notify-render() -- Render function for notifications. See notify-render()
render = "default", render = "default",

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
[[ "$(upower -i $(upower -e | grep 'BAT'))" == "" ]] && exit [[ "$(upower -i "$(upower -e | grep 'BAT')")" == "" ]] && exit
current=$(upower -i $(upower -e | grep 'BAT') | grep -E "percentage" | sed 's/.*://' | sed 's/ *//') current=$(upower -i "$(upower -e | grep 'BAT')" | grep -E "percentage" | sed 's/.*://' | sed 's/ *//')
state=$(upower -i $(upower -e | grep 'BAT') | grep -E "state" | sed 's/.*://' | sed 's/ *//') state=$(upower -i "$(upower -e | grep 'BAT')" | grep -E "state" | sed 's/.*://' | sed 's/ *//')
if [[ "$state" == "not charging" ]]; then if [[ "$state" == "not charging" ]]; then
state="full" state="full"
fi fi
echo "$current $state" echo "$current $state"

View File

@ -1,22 +1,22 @@
#!/bin/bash #!/bin/bash
if git status &>/dev/null; then if git status &>/dev/null; then
branch=$(git branch --show-current) branch=$(git branch --show-current)
if [ -z "$branch" ]; then if [ -z "$branch" ]; then
echo "(detached)" echo "(detached)"
exit 0 exit 0
fi fi
read -ra counts <<< "$(git rev-list --left-right --count "$branch"...origin/"$branch")" read -ra counts <<< "$(git rev-list --left-right --count "$branch"...origin/"$branch")"
to_push=${counts[0]} to_push=${counts[0]}
to_pull=${counts[1]} to_pull=${counts[1]}
extras=$([[ ${counts[0]} -eq 0 && ${counts[1]} -eq 0 ]] || echo " $to_push↑ $to_pull↓") extras=$([[ ${counts[0]} -eq 0 && ${counts[1]} -eq 0 ]] || echo " $to_push↑ $to_pull↓")
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
echo "($branch*$extras)" echo "($branch*$extras)"
else else
echo "($branch~$extras)" echo "($branch~$extras)"
fi fi
fi fi

View File

@ -1,17 +0,0 @@
#!/bin/sh
# Syncs repositories and downloads updates, meant to be run as a cronjob.
notify-send "📦 Repository Sync" "Checking for package updates..."
sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
Check your internet connection, if pacman is already running, or run update manually to see errors."
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
if pacman -Qu | grep -v "\[ignored\]"
then
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
else
notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
fi

View File

@ -9,7 +9,7 @@ if [[ -z $selected ]]; then
exit 0 exit 0
fi fi
read -p "Enter Query: " query read -rp "Enter Query: " query
if grep -qs "$selected" "$languages"; then if grep -qs "$selected" "$languages"; then
query=$(echo "$query" | tr ' ' '+') query=$(echo "$query" | tr ' ' '+')

View File

@ -17,43 +17,43 @@ ext="${file##*.}"
cd "$dir" || exit 1 cd "$dir" || exit 1
textype() { \ textype() { \
textarget="$(getcomproot "$file" || echo "$file")" textarget="$(getcomproot "$file" || echo "$file")"
echo "$textarget" echo "$textarget"
command="pdflatex" command="pdflatex"
( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex" ( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex"
$command --output-directory="${textarget%/*}" "${textarget%.*}" $command --output-directory="${textarget%/*}" "${textarget%.*}"
grep -qi addbibresource "$textarget" && grep -qi addbibresource "$textarget" &&
biber --input-directory "${textarget%/*}" "${textarget%.*}" && biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
$command --output-directory="${textarget%/*}" "${textarget%.*}" && $command --output-directory="${textarget%/*}" "${textarget%.*}" &&
$command --output-directory="${textarget%/*}" "${textarget%.*}" $command --output-directory="${textarget%/*}" "${textarget%.*}"
} }
case "$ext" in case "$ext" in
# Try to keep these cases in alphabetical order. # Try to keep these cases in alphabetical order.
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;; [0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
c) cc "$file" -o "$base" && "$base" ;; c) cc "$file" -o "$base" && "$base" ;;
cpp) g++ "$file" -o "$base" && "$base" ;; cpp) g++ "$file" -o "$base" && "$base" ;;
cs) mcs "$file" && mono "$base".exe ;; cs) mcs "$file" && mono "$base".exe ;;
go) go run "$file" ;; go) go run "$file" ;;
h) sudo make install ;; h) sudo make install ;;
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;; java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
m) octave "$file" ;; m) octave "$file" ;;
md) if [ -x "$(command -v lowdown)" ]; then md) if [ -x "$(command -v lowdown)" ]; then
lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf
elif [ -x "$(command -v groffdown)" ]; then elif [ -x "$(command -v groffdown)" ]; then
groffdown -i "$file" | groff -T pdf > "$base".pdf groffdown -i "$file" | groff -T pdf > "$base".pdf
else else
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file" pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
fi ; ;; fi ; ;;
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;; mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;; ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;; org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;;
py) python "$file" ;; py) python "$file" ;;
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;; [rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
rs) cargo build ;; rs) cargo build ;;
sass) sassc -a "$file" "$base".css ;; sass) sassc -a "$file" "$base".css ;;
scad) openscad -o "$base".stl "$file" ;; scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;; sent) setsid -f sent "$file" 2>/dev/null ;;
tex) textype "$file" ;; tex) textype "$file" ;;
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;; *) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
esac esac

View File

@ -2,16 +2,15 @@
# Syncs repositories and downloads updates, meant to be run as a cronjob. # Syncs repositories and downloads updates, meant to be run as a cronjob.
notify-send "📦 Repository Sync" "Checking for package updates..." notify-send "Repository Sync" "Checking for package updates..."
sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates. sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
Check your internet connection, if pacman is already running, or run update manually to see errors." Check your internet connection, if pacman is already running, or run update manually to see errors."
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
if pacman -Qu | grep -v "\[ignored\]" if pacman -Qu | grep -v "\[ignored\]"
then then
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update." notify-send "Repository Sync" "Sync comelete. You have updates $(pacman -Qu | grep -vc "\[ignored\]") available."
else else
notify-send "📦 Repository Sync" "Sync complete. No new packages for update." notify-send "Repository Sync" "Sync complete. No new packages for update."
fi fi

View File

@ -3,4 +3,4 @@
# Toggles all cronjobs off/on. # Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.config/cronsaved until restored. # Stores disabled crontabs in ~/.config/cronsaved until restored.
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.") ([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "Cronjobs saved and disabled.")

View File

@ -1,6 +0,0 @@
#!/bin/sh
# Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.config/cronsaved until restored.
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
default_loc=/tmp/pactl-default-sink default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then if [ ! -f "$default_loc" ] ; then
set-default-sink set-default-sink
fi fi
default=$(cat $default_loc) default="$(<"$default_loc")"
pactl set-sink-volume $default -5% pactl set-sink-volume "$default" -5%

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
default_loc=/tmp/pactl-default-source default_loc="$HOME/.cache/pactl-default-source"
if [ ! -f "$default_loc" ] ; then if [ ! -f "$default_loc" ] ; then
set-default-source set-default-source
fi fi
default=$(cat $default_loc) default="$(<"$default_loc")"
pactl set-source-volume $default -5% pactl set-source-volume "$default" -5%

View File

@ -36,31 +36,31 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0 xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
fi fi
} }
morescreen() { # If multi-monitor is selected and there are more than two screens. morescreen() { # If multi-monitor is selected and there are more than two screens.
primary=$(echo "$screens" | dmenu -i -p "Select primary display:") primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:") secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") direction=$(printf "left\\nright" | 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:") tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
} }
multimon() { # Multi-monitor handler. multimon() { # Multi-monitor handler.
case "$(echo "$screens" | wc -l)" in case "$(echo "$screens" | wc -l)" in
2) twoscreen ;; 2) twoscreen ;;
*) morescreen ;; *) morescreen ;;
esac ;} esac ;}
onescreen() { # If only one output available or chosen. onescreen() { # If only one output available or chosen.
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -) xrandr --output "$1" --auto --scale 1.0x1.0 "$(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)"
} }
postrun() { # Stuff to run to clean up. postrun() { # Stuff to run to clean up.
setbg # Fix background if screen size/arangement has changed. setbg # Fix background if screen size/arangement has changed.
remaps # Re-remap keys if keyboard added (for laptop bases) 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 { killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
} }
# Get all possible displays # Get all possible displays
allposs=$(xrandr -q | grep "connected") allposs=$(xrandr -q | grep "connected")
@ -70,14 +70,14 @@ screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
# If there's only one screen # If there's only one screen
[ "$(echo "$screens" | wc -l)" -lt 2 ] && [ "$(echo "$screens" | wc -l)" -lt 2 ] &&
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;} { 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: # Get user choice including multi-monitor and manual selection:
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") && chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
case "$chosen" in case "$chosen" in
"manual selection") arandr ; exit ;; "manual selection") arandr ; exit ;;
"multi-monitor") multimon ;; "multi-monitor") multimon ;;
*) onescreen "$chosen" ;; *) onescreen "$chosen" ;;
esac esac
postrun postrun

View File

@ -6,62 +6,62 @@
# input a novel directory, it will prompt you to create that directory. # input a novel directory, it will prompt you to create that directory.
getmount() { \ getmount() { \
[ -z "$chosen" ] && exit 1 [ -z "$chosen" ] && exit 1
# shellcheck disable=SC2086 # shellcheck disable=SC2086
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1 mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
test -z "$mp" && exit 1 test -z "$mp" && exit 1
if [ ! -d "$mp" ]; then if [ ! -d "$mp" ]; then
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1 mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp") [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
fi fi
} }
mountusb() { \ mountusb() { \
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1 chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')" chosen="$(echo "$chosen" | awk '{print $1}')"
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0 sudo -A mount "$chosen" 2>/dev/null && notify-send "USB mounting" "$chosen mounted." && exit 0
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}') alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted" getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
partitiontype="$(lsblk -no "fstype" "$chosen")" partitiontype="$(lsblk -no "fstype" "$chosen")"
case "$partitiontype" in case "$partitiontype" in
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000 ;;
"exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)";; "exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)" ;;
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";; *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp" ;;
esac && notify-send "💻 USB mounting" "$chosen mounted to $mp." || esac && notify-send "USB mounting" "$chosen mounted to $mp." ||
notify-send "💻 Drive failed to mount." "Probably a permissions issue or drive is already mounted." notify-send "Drive failed to mount." "Probably a permissions issue or drive is already mounted."
} }
mountandroid() { \ mountandroid() { \
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1 chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
chosen="$(echo "$chosen" | cut -d : -f 1)" chosen="$(echo "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d" getmount "$HOME -maxdepth 3 -type d"
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1 echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
simple-mtpfs --device "$chosen" "$mp" && simple-mtpfs --device "$chosen" "$mp" &&
notify-send "🤖 Android Mounting" "Android device mounted to $mp." || notify-send "Android Mounting" "Android device mounted to $mp." ||
notify-send "🤖 Android failed mounting." "Probably a permissions issue or phone is already mounted." notify-send "Android failed mounting." "Probably a permissions issue or phone is already mounted."
} }
asktype() { \ asktype() { \
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1 choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
case $choice in case $choice in
USB) mountusb ;; USB) mountusb ;;
Android) mountandroid ;; Android) mountandroid ;;
esac esac
} }
anddrives=$(simple-mtpfs -l 2>/dev/null) anddrives=$(simple-mtpfs -l 2>/dev/null)
usbdrives="$(lsblk -rpo "name,type,size,label,mountpoint,fstype" | grep -v crypto_LUKS | grep 'part\|rom' | sed 's/ /:/g' | awk -F':' '$5==""{printf "%s (%s) %s\n",$1,$3,$4}')" usbdrives="$(lsblk -rpo "name,type,size,label,mountpoint,fstype" | grep -v crypto_LUKS | grep 'part\|rom' | sed 's/ /:/g' | awk -F':' '$5==""{printf "%s (%s) %s\n",$1,$3,$4}')"
if [ -z "$usbdrives" ]; then if [ -z "$usbdrives" ]; then
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
echo "Android device(s) detected." echo "Android device(s) detected."
mountandroid mountandroid
else else
if [ -z "$anddrives" ]; then if [ -z "$anddrives" ]; then
echo "USB drive(s) detected." echo "USB drive(s) detected."
mountusb mountusb
else else
echo "Mountable USB drive(s) and Android device(s) detected." echo "Mountable USB drive(s) and Android device(s) detected."
asktype asktype
fi fi
fi fi

View File

@ -8,14 +8,14 @@
# Taken shamelessly from Luke Smith # Taken shamelessly from Luke Smith
if [ -n "$3" ] if [[ -n "$3" ]]
then then
choice=$(echo -e "Yes\nNo" | dmenu -bw 0 -i -p "$1") choice=$(echo -e "Yes\nNo" | dmenu -bw 0 -i -p "$1")
else else
choice=$(echo -e "No\nYes" | dmenu -bw 0 -i -p "$1") choice=$(echo -e "No\nYes" | dmenu -bw 0 -i -p "$1")
fi fi
if [ $choice = "Yes" ] if [[ "$choice" = "Yes" ]]
then then
$2 $2
fi fi

View File

@ -4,7 +4,7 @@
# Description: Search various search engines (inspired by surfraw). # Description: Search various search engines (inspired by surfraw).
# Dependencies: dmenu and a web browser # Dependencies: dmenu and a web browser
# Usage: dmenusearch <engine> # Usage: dmenusearch <engine>
# where engine is amazon, duckduckgo, etc. # where engine is amazon, duckduckgo, etc.
# without engine all options will be listed # without engine all options will be listed
# Pilfered from Derek Taylor @ https://www.gitlab.com/dwt1/dmscripts # Pilfered from Derek Taylor @ https://www.gitlab.com/dwt1/dmscripts
@ -88,4 +88,4 @@ while [ -z "$query" ]; do
done done
# Display search results in web browser # Display search results in web browser
$DMBROWSER "$url""$query" $DMBROWSER "$url" "$query"

View File

@ -9,13 +9,13 @@ drives="$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,"
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1 chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
case "$chosen" in case "$chosen" in
📱*) 📱*)
chosen="${chosen#📱 }" chosen="${chosen#📱 }"
sudo -A umount -l "$chosen" sudo -A umount -l "$chosen"
;; ;;
*) *)
chosen="${chosen% (*}" chosen="${chosen% (*}"
sudo -A umount -l "$chosen" sudo -A umount -l "$chosen"
;; ;;
esac && notify-send "🖥️ Drive unmounted." "$chosen successfully unmounted." || esac && notify-send "Drive unmounted." "$chosen successfully unmounted." ||
notify-send "🖥️ Drive failed to unmount." "Possibly a permissions or I/O issue." notify-send "Drive failed to unmount." "Possibly a permissions or I/O issue."

View File

@ -7,39 +7,39 @@
# Behavior with `-c` option: Extract contents into current directory # Behavior with `-c` option: Extract contents into current directory
while getopts "hc" o; do case "${o}" in while getopts "hc" o; do case "${o}" in
c) extracthere="True" ;; c) extracthere="True" ;;
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit 1 ;; *) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit 1 ;;
esac done esac done
if [ -z "$extracthere" ]; then if [ -z "$extracthere" ]; then
archive="$(readlink -f "$*")" && archive="$(readlink -f "$*")" &&
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" && directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
mkdir -p "$directory" && mkdir -p "$directory" &&
cd "$directory" || exit 1 cd "$directory" || exit 1
else else
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2>/dev/null)" archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2>/dev/null)"
fi fi
[ -z "$archive" ] && printf "Give archive to extract as argument.\\n" && exit 1 [ -z "$archive" ] && printf "Give archive to extract as argument.\\n" && exit 1
if [ -f "$archive" ] ; then if [ -f "$archive" ] ; then
case "$archive" in case "$archive" in
*.tar.bz2|*.tbz2) tar xvjf "$archive" ;; *.tar.bz2|*.tbz2) tar xvjf "$archive" ;;
*.tar.xz) tar -xf "$archive" ;; *.tar.xz) tar -xf "$archive" ;;
*.tar.gz|*.tgz) tar xvzf "$archive" ;; *.tar.gz|*.tgz) tar xvzf "$archive" ;;
*.tar.zst) tar -I zstd -xf "$archive" ;; *.tar.zst) tar -I zstd -xf "$archive" ;;
*.lzma) unlzma "$archive" ;; *.lzma) unlzma "$archive" ;;
*.bz2) bunzip2 "$archive" ;; *.bz2) bunzip2 "$archive" ;;
*.rar) unrar x -ad "$archive" ;; *.rar) unrar x -ad "$archive" ;;
*.gz) gunzip "$archive" ;; *.gz) gunzip "$archive" ;;
*.tar) tar xvf "$archive" ;; *.tar) tar xvf "$archive" ;;
*.zip) unzip "$archive" ;; *.zip) unzip "$archive" ;;
*.Z) uncompress "$archive" ;; *.Z) uncompress "$archive" ;;
*.7z) 7z x "$archive" ;; *.7z) 7z x "$archive" ;;
*.xz) unxz "$archive" ;; *.xz) unxz "$archive" ;;
*.exe) cabextract "$archive" ;; *.exe) cabextract "$archive" ;;
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;; *) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
esac esac
else else
printf "File \"%s\" not found.\\n" "$archive" printf "File \"%s\" not found.\\n" "$archive"
fi fi

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
default_loc=/tmp/pactl-default-sink default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then if [ ! -f "$default_loc" ] ; then
set-default-sink set-default-sink
fi fi
default=$(cat $default_loc) default=$(<"$default_loc")
pactl set-sink-volume $default +5% pactl set-sink-volume "$default" +5%

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
default_loc=/tmp/pactl-default-source default_loc="$HOME/.cache/pactl-default-source"
if [ ! -f "$default_loc" ] ; then if [ ! -f "$default_loc" ] ; then
set-default-source set-default-source
fi fi
default=$(cat $default_loc) default=$(<"$default_loc")
pactl set-source-volume $default +5% pactl set-source-volume "$default" +5%

View File

@ -1,8 +0,0 @@
#!/bin/bash
shopt -s nullglob
for g in /sys/kernel/iommu_groups/*; do
echo "IOMMU Group ${g##*/}:"
for d in $g/devices/*; do
echo -e "\t$(lspci -nns ${d##*/})"
done;
done;

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
fn="/tmp/kbswitcher.status" fn="$HOME/.cache/kbswitcher-status"
layout="" layout=""
@ -13,11 +13,11 @@ else
us) us)
echo "dvorak" > "$fn" echo "dvorak" > "$fn"
layout="dvorak" layout="dvorak"
;; ;;
dvorak) dvorak)
echo "us" > "$fn" echo "us" > "$fn"
layout="us" layout="us"
;; ;;
esac esac
fi fi

View File

@ -1,19 +1,19 @@
#!/bin/bash #!/bin/bash
if command -v brillo &> /dev/null; then if command -v brillo &> /dev/null; then
function send_notification() { function send_notification() {
brightness=$(printf "%.0f\n" $(brillo -G)) brightness=$(printf "%.0f\n" "$(brillo -G)")
dunstify -a "changebrightness" -u low -r 9991 -h int:value:"$brightness" -i "brightness-$1" "Brightness: $brightness%" -t 2000 dunstify -a "changebrightness" -u low -r 9991 -h int:value:"$brightness" -i "brightness-$1" "Brightness: $brightness%" -t 2000
} }
case $1 in case $1 in
up) up)
brillo -A 5 -q -u 150000 brillo -A 5 -q -u 150000
send_notification $1 send_notification "$1"
;; ;;
down) down)
brillo -U 5 -q -u 150000 brillo -U 5 -q -u 150000
send_notification $1 send_notification "$1"
;; ;;
esac esac
fi fi

View File

@ -1,7 +1,8 @@
#!/bin/sh #!/bin/bash
if [[ -x "$1" ]]; then if [[ ! -x "$1" ]]; then
$1 echo "$1 does not exist or couldn't be executed."
else exit 1
echo "$1 does not exist or couldn't be executed."
fi fi
$1

View File

@ -1,16 +1,17 @@
#!/bin/bash #!/bin/bash
layouts=($(ls "$HOME/.screenlayout/")) layouts=("$(ls "$HOME/.screenlayout/")")
add="add layout..." add="add layout..."
layouts+=("$add") layouts+=("$add")
choice=$( printf '%s\n' "${layouts[@]}" | dmenu -i -p 'Choose a screenlayout:') "$@" || exit choice=$(printf '%s\n' "${layouts[@]}" | dmenu -i -p 'Choose a screenlayout:') || exit 0
if [ "$choice" = "$add" ] if [ "$choice" = "$add" ]
then then
arandr & arandr &
else exit 0
exec "$HOME/.screenlayout/$choice"
fi fi
exec "$HOME/.screenlayout/$choice"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/bash
SCRIPTNAME=$(basename $0) SCRIPTNAME=$(basename "$0")
FILENAME="$HOME/$SCRIPTNAME-$(date +'%Y-%m-%d-%H-%M-%S').png" FILENAME="$HOME/$SCRIPTNAME-$(date +'%Y-%m-%d-%H-%M-%S').png"
case ${1:-} in case ${1:-} in
@ -9,5 +9,5 @@ case ${1:-} in
esac esac
maim --format=png $SEL "$FILENAME" maim --format=png $SEL "$FILENAME"
echo -n $FILENAME | xclip -selection clipbard echo -n "$FILENAME" | xclip -selection clipbard
notify-send "Screenshot" "$(echo -e "Screen shot saved\n$FILENAME")" notify-send "Screenshot" "$(echo -e "Screen shot saved\n$FILENAME")"

View File

@ -6,8 +6,9 @@ if [ -z "$choice" ] ; then
exit 0; exit 0;
fi fi
default_loc="$HOME/.cache/pactl-default-sink"
rm /tmp/pactl-default-sink --force # to ignore if it isn't there rm "$default_loc" --force # to ignore if it isn't there
touch /tmp/pactl-default-sink touch "$default_loc"
echo "$choice" > /tmp/pactl-default-sink echo "$choice" > "$default_loc"
pactl set-default-sink $choice # make sure that the chosen sink is the pactl set-default-sink "$choice" # make sure that the chosen sink is the

View File

@ -6,8 +6,9 @@ if [ -z "$choice" ] ; then
exit 0; exit 0;
fi fi
default_loc="$HOME/.cache/pactl-default-source"
rm /tmp/pactl-default-source --force # to ignore if it isn't there rm "$default_loc" --force # to ignore if it isn't there
touch /tmp/pactl-default-source touch "$default_loc"
echo "$choice" > /tmp/pactl-default-source echo "$choice" > "$default_loc"
pactl set-default-source $choice # make sure that the chosen sink is the pactl set-default-source "$choice" # make sure that the chosen sink is the

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
default_loc=/tmp/pactl-default-sink default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then if [ ! -f "$default_loc" ] ; then
set-default-sink set-default-sink
fi fi
default=$(cat $default_loc) default=$(<"$default_loc")
value=$(echo -e "" | dmenu -bw 0 -i -p "Set vol to what?") value=${1-$(echo -e "" | dmenu -bw 0 -i -p "Set vol to what?")}
pactl set-sink-volume $default $value% pactl set-sink-volume "$default" "$value%"

View File

@ -2,43 +2,44 @@
icon="" icon=""
status=$(bash-status-bat) IFS=" " read -ra parts <<< "$(bash-status-bat)"
parts=($status)
current=$(echo "${parts[0]}" | sed 's/\%//') parts_0=${parts[0]}
current=${parts_0//\%/}
state=${parts[1]} state=${parts[1]}
status="$current%" status="$current%"
if [[ "$state" == "discharging" ]]; then if [[ "$state" == "discharging" ]]; then
case $(((current/20)+1)) in case $((current/20+1)) in
1) 1)
icon=" " icon=" "
;; ;;
2) 2)
icon=" " icon=" "
;; ;;
3) 3)
icon=" " icon=" "
;; ;;
4) 4)
icon=" " icon=" "
;; ;;
5) 5)
icon=" " icon=" "
;; ;;
esac esac
fi fi
if [[ "$state" == "not-charging" ]]; then case $state in
icon=" " not-charging)
fi icon=" "
;;
if [[ "$state" == "fully-charged" ]]; then fully-charged)
icon=" " icon=" "
status="Full" status="Full"
fi ;;
charging)
if [[ "$state" == "charging" ]]; then icon=" "
icon=" " ;;
fi esac
echo "$icon $status" echo "$icon $status"

View File

@ -3,8 +3,8 @@
freemb=$(df -h -B 1048576 | grep "/$" | awk -F ' ' '{ print $4 }') freemb=$(df -h -B 1048576 | grep "/$" | awk -F ' ' '{ print $4 }')
freegb=$(df -h -B 1048576 | grep "/$" | awk -F ' ' '{ print $4/1024 }') freegb=$(df -h -B 1048576 | grep "/$" | awk -F ' ' '{ print $4/1024 }')
if [ $freemb -lt 1024 ]; then if [ "$freemb" -lt 1024 ]; then
printf " %0.2fMb" $freemb printf " %0.2fMb" "$freemb"
else else
printf " %0.2fGb" $freegb printf " %0.2fGb" "$freegb"
fi fi

View File

@ -1,35 +1,15 @@
#!/bin/sh #!/bin/bash
dev_wifi=$(cat "$HOME"/.config/net-cfg/dev_wifi) dev_wifi=$(<"$HOME"/.config/net-cfg/dev_wifi)
dev_eth=$(cat "$HOME"/.config/net-cfg/dev_eth) dev_eth=$(<"$HOME"/.config/net-cfg/dev_eth)
dev_vpn=$(cat "$HOME"/.config/net-cfg/dev_vpn) dev_vpn=$(<"$HOME"/.config/net-cfg/dev_vpn)
base03=#002b36
base02=#073642
base01=#586e75
base00=#657b83
base0=#839496
base1=#93a1a1
base2=#eee8d5
base3=#fdf6e3
yellow=#b58900
orange=#cb4b16
red=#dc322f
magenta=#d33682
violet=#6c71c4
blue=#268bd2
cyan=#2aa198
green=#859900
std_color=$magenta
wifi_icon=" " wifi_icon=" "
color=$std_color;
eth="$(ip -o address | grep -i "$dev_eth *inet ")" eth="$(ip -o address | grep -i "$dev_eth *inet ")"
if [ -n "$eth" ] if [ -n "$eth" ]
then then
speed="$(cat /sys/class/net/$dev_eth/speed)" speed="$(cat "/sys/class/net/$dev_eth/speed")"
case $speed in case $speed in
10) speed="10Base-T" ;; 10) speed="10Base-T" ;;
100) speed="100Base-T" ;; 100) speed="100Base-T" ;;
@ -39,7 +19,7 @@ then
eth_status="  $speed" eth_status="  $speed"
fi fi
ssid="$(iw dev $dev_wifi link | grep -i SSID)" ssid="$(iw dev "$dev_wifi" link | grep -i SSID)"
if [ -n "$ssid" ] if [ -n "$ssid" ]
then then
signal="$(awk '/^\s*w/ { print int($3 * 100 / 70) "%" }' /proc/net/wireless)" signal="$(awk '/^\s*w/ { print int($3 * 100 / 70) "%" }' /proc/net/wireless)"
@ -50,12 +30,8 @@ vpn="$(ip -o address | grep -i "$dev_vpn *inet ")"
if [ -n "$vpn" ] if [ -n "$vpn" ]
then then
vpn_status="" vpn_status=""
color=$green
else else
vpn_status="" vpn_status=""
fi fi
echo "${vpn_status} $wifi_status$eth_status" echo "${vpn_status} $wifi_status$eth_status"
# vim: ft=sh:expandtab:ts=4:shiftwidth=4

View File

@ -8,20 +8,21 @@ vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
[ "$vol" != "${vol%\[MUTED\]}" ] && echo  && exit [ "$vol" != "${vol%\[MUTED\]}" ] && echo  && exit
vol="${vol#Volume: }" vol="${vol#Volume: }"
split() { split() {
# For ommiting the . without calling and external program. # For ommiting the . without calling and external program.
IFS=$2 IFS=$2
set -- $1 set -- $1
printf '%s' "$@" printf '%s' "$@"
} }
vol="$(split "$vol" ".")" vol="$(split "$vol" ".")"
vol="${vol##0}" vol="${vol##0}"
case 1 in case 1 in
$((vol >= 70)) ) icon="" ;; $((vol >= 70)) ) icon="" ;;
$((vol >= 30)) ) icon="" ;; $((vol >= 30)) ) icon="" ;;
$((vol >= 1)) ) icon="" ;; $((vol >= 1)) ) icon="" ;;
* ) echo  && exit ;; * ) echo  && exit ;;
esac esac
echo "$icon $vol%" echo "$icon $vol%"

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
branch_name=$(basename $1) branch_name=$(basename "$1")
session_name=$(tmux display-message -p "#S") session_name=$(tmux display-message -p "#S")
clean_name=$(echo $branch_name | tr "./" "__") clean_name=$(echo "$branch_name" | tr "./" "__")
target="$session_name:$clean_name" target="$session_name:$clean_name"
if ! tmux has-session -t $target 2> /dev/null; then if ! tmux has-session -t "$target" 2> /dev/null; then
tmux neww -dn $clean_name tmux neww -dn "$clean_name"
fi fi
shift shift
tmux send-keys -t $target "$*" Enter tmux send-keys -t "$target" "$*" Enter

View File

@ -3,12 +3,9 @@
session="system" session="system"
# Check if the session exists, discarding output # Check if the session exists, discarding output
# We can check $? for the exit status (zero for success, non-zero for failure) if command -v tmux has-session -t $session 2>/dev/null != 0; then
tmux has-session -t $session 2>/dev/null # Set up your session
tmux new-session -s "$session"
if [ $? != 0 ]; then
# Set up your session
tmux new-session -s "$session"
fi fi
# Attach to created session # Attach to created session

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
default_loc=/tmp/pactl-default-sink default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then if [ ! -f "$default_loc" ] ; then
set-default-sink set-default-sink
fi fi
default=$(cat $default_loc) default=$(cat "$default_loc")
pactl set-sink-mute $default toggle pactl set-sink-mute "$default" toggle

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
default_loc=/tmp/pactl-default-source default_loc="$HOME/.cache/pactl-default-source"
if [ ! -f "$default_loc" ] ; then if [ ! -f "$default_loc" ] ; then
set-default-source set-default-source
fi fi
default=$(cat $default_loc) default=$(cat "$default_loc")
pactl set-source-mute $default toggle pactl set-source-mute "$default" toggle

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
test_path="/tmp/trayer.exists" test_path="$HOME/.cache/trayer-exists"
if [ -f "$test_path" ]; then if [ -f "$test_path" ]; then
echo "stopping trayer" echo "stopping trayer"

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
cmd=$(command -v $1) cmd=$(command -v "$1")
test -n "$cmd" && exec vi "$cmd" test -n "$cmd" && exec vi "$cmd"

View File

@ -1,9 +1,5 @@
#!/bin/bash #!/bin/bash
# a simple wrapper for inserting xmobar stuff # a simple wrapper for inserting xmobar stuff
IFS=" " read -r -a parts <<< "$(status-bat)"
status=$(status-bat)
parts=($status)
echo "<fn=1>${parts[0]} </fn> ${parts[1]}" echo "<fn=1>${parts[0]} </fn> ${parts[1]}"

View File

@ -1,7 +1,4 @@
#!/bin/bash #!/bin/bash
status=$(status-disk) IFS=" " read -r -a parts <<< "$(status-disk)"
parts=($status)
echo "<fn=1>${parts[0]} </fn> ${parts[1]}" echo "<fn=1>${parts[0]} </fn> ${parts[1]}"

View File

@ -3,30 +3,14 @@
stdlayout=us # standard layout takes "default" color stdlayout=us # standard layout takes "default" color
stdname=en-us # arbitrary, descriptive only stdname=en-us # arbitrary, descriptive only
base03=#002b36
base02=#073642
base01=#586e75
base00=#657b83
base0=#839496
base1=#93a1a1
base2=#eee8d5
base3=#fdf6e3
yellow=#b58900
orange=#cb4b16
red=#dc322f
magenta=#d33682 magenta=#d33682
violet=#6c71c4
blue=#268bd2
cyan=#2aa198
green=#859900 green=#859900
layout="$(xkb-switch)" layout="$(xkb-switch)"
case $layout in case $layout in
${stdlayout}) color=$green; icon=" "; name=$stdname ;; # f11c fa-keyboard-o "${stdlayout}") color=$green; icon=" "; name=$stdname ;; # f11c fa-keyboard-o
*) color=$magenta; icon=""; name="dvorak" ;; # f11c fa-keyboard-o *) color=$magenta; icon=""; name="dvorak" ;; # f11c fa-keyboard-o
esac esac
echo "<fc=$color><fn=1>$icon </fn> ${name}</fc>" echo "<fc=$color><fn=1>$icon </fn> ${name}</fc>"
# vim: ft=sh:expandtab:ts=4:shiftwidth=4

View File

@ -1,24 +1,12 @@
#!/bin/sh #!/bin/bash
dev_wifi=$(cat "$HOME"/.config/xmobar/dev_wifi) dev_wifi=$(cat "$HOME"/.config/xmobar/dev_wifi)
dev_eth=$(cat "$HOME"/.config/xmobar/dev_eth) dev_eth=$(cat "$HOME"/.config/xmobar/dev_eth)
dev_vpn=$(cat "$HOME"/.config/xmobar/dev_vpn) dev_vpn=$(cat "$HOME"/.config/xmobar/dev_vpn)
# base03=#002b36
# base02=#073642
# base01=#586e75
# base00=#657b83
# base0=#839496
# base1=#93a1a1
# base2=#eee8d5
# base3=#fdf6e3
yellow=#b58900 yellow=#b58900
# orange=#cb4b16
red=#dc322f red=#dc322f
magenta=#d33682 magenta=#d33682
# violet=#6c71c4
# blue=#268bd2
# cyan=#2aa198
green=#859900 green=#859900
# connectivity status # connectivity status
@ -82,6 +70,3 @@ else
fi fi
echo "<fc=$color>${vpn_status}<fn=1>$icon </fn>${connectivity##*full}$wifi_status$eth_status</fc>" echo "<fc=$color>${vpn_status}<fn=1>$icon </fn>${connectivity##*full}$wifi_status$eth_status</fc>"
# vim: ft=sh:expandtab:ts=4:shiftwidth=4

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
count=$(yay -Qu | wc -l) count=$(pacman -Qu | wc -l)
icon="" icon=""
echo "<fn=1>$icon </fn> $count" echo "<fn=1>$icon </fn> $count"

View File

@ -1,46 +1,33 @@
#!/bin/sh #!/bin/sh
base03=#002b36
base02=#073642
base01=#586e75
base00=#657b83
base0=#839496
base1=#93a1a1
base2=#eee8d5
base3=#fdf6e3
yellow=#b58900
orange=#cb4b16 orange=#cb4b16
red=#dc322f red=#dc322f
magenta=#d33682
violet=#6c71c4
blue=#268bd2
cyan=#2aa198 cyan=#2aa198
green=#859900
color=$cyan color=$cyan
vol="$(pamixer --get-volume)" vol="$(pamixer --get-volume)"
if [ $(pamixer --get-mute) = true ]; then if [ "$(pamixer --get-mute)" = true ]; then
vol=MUTE vol=MUTE
color=$red color=$red
icon="" # fa-volume-off f026 icon="" # fa-volume-off f026
echo "<fc=$color><fn=1>$icon </fn>$vol</fc>" echo "<fc=$color><fn=1>$icon </fn>$vol</fc>"
fi fi
if [ "$vol" -gt "100" ]; then if [ "$vol" -gt "100" ]; then
icon="" icon=""
color=$orange color=$orange
elif [ "$vol" -gt "70" ]; then elif [ "$vol" -gt "70" ]; then
icon="" icon=""
elif [ "$vol" -gt "30" ]; then elif [ "$vol" -gt "30" ]; then
icon="" icon=""
elif [ "$vol" -gt "0" ]; then elif [ "$vol" -gt "0" ]; then
icon="" icon=""
else else
vol=MUTE vol=MUTE
color=$red color=$red
icon="" icon=""
fi fi
echo "<fc=$color><fn=1>$icon </fn>$vol</fc>" echo "<fc=$color><fn=1>$icon </fn>$vol</fc>"

View File

@ -1,15 +1,15 @@
#!/bin/sh #!/bin/bash
# simple script to read weather from airport code and return it for display in xmobar # simple script to read weather from airport code and return it for display in xmobar
weather=$(weather-report $1 -m --no-cache -n | \ weather=$(weather-report "$1" -m --no-cache -n | \
grep -e '\[' \ grep -e '\[' \
-e 'Temp' | \ -e 'Temp' | \
sed -e 's/\[using result //' \ sed -e 's/\[using result //' \
-e 's/,.*\]//' \ -e 's/,.*\]//' \
-e 's/Temp.*: //' \ -e 's/Temp.*: //' \
-e 's/ C//' \ -e 's/ C//' \
-e 's/ //') -e 's/ //')
readarray -t y <<< "$weather" readarray -t y <<< "$weather"
@ -19,18 +19,18 @@ color=""
if ((temp > 30)) if ((temp > 30))
then then
color="#ff5555" color="#ff5555"
elif ((temp > 25)) elif ((temp > 25))
then then
color="#ffb86c" color="#ffb86c"
elif ((temp > 20)) elif ((temp > 20))
then then
color="#f1fa8c" color="#f1fa8c"
elif ((temp > 10)) elif ((temp > 10))
then then
color="#50fa7b" color="#50fa7b"
else else
color="#8be9fd" color="#8be9fd"
fi fi
echo -e "<fc=#ff79c6>$loc <fc=$color>$temp</fc>C</fc>" echo -e "<fc=#ff79c6>$loc <fc=$color>$temp</fc>C</fc>"

View File

@ -40,8 +40,8 @@ width=$(xprop -name panel | grep 'program specified minimum size' | cut -d ' ' -
iconfile="/tmp/trayer-padding-${width}px.xpm" iconfile="/tmp/trayer-padding-${width}px.xpm"
# If the desired icon does not exist create it # If the desired icon does not exist create it
if [ ! -f $iconfile ]; then if [ ! -f "$iconfile" ]; then
create_xpm_icon $width $iconfile create_xpm_icon "$width" "$iconfile"
fi fi
# Output the icon tag for xmobar # Output the icon tag for xmobar

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
sed -n '/--START_KEYS/,/--END_KEYS/p' $HOME/.xmonad/xmonad.hs | \ sed -n '/--START_KEYS/,/--END_KEYS/p' "$HOME/.xmonad/xmonad.hs" | \
grep -e ', ("' \ grep -e ', ("' \
-e '\[ ("' \ -e '\[ ("' \
-e '--NOTE' | \ -e '--NOTE' | \
@ -9,4 +9,4 @@ sed -n '/--START_KEYS/,/--END_KEYS/p' $HOME/.xmonad/xmonad.hs | \
-e 's/\[ (/(/' \ -e 's/\[ (/(/' \
-e 's/--NOTE /\n/' \ -e 's/--NOTE /\n/' \
-e 's/, / --> /' | \ -e 's/, / --> /' | \
yad --text-info --back=#121e32 --fore=#dfdfef --geometry=1200x800 yad --text-info --back=#121e32 --fore=#dfdfef --geometry=1200x800