Skip to content

Commit

Permalink
Update bar scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
saloniamatteo committed Nov 15, 2024
1 parent 7c0fb33 commit 46c1bfc
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 201 deletions.
43 changes: 21 additions & 22 deletions scripts/.local/bin/battery
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,32 @@
case $BLOCK_BUTTON in
3) notify-send "🔋 Battery module" "🔋: discharging
🛑: not charging
: stagnant charge
♻: stagnant charge
🔌: charging
⚡: charged
❗: battery very low!
📛: no battery attached
- Scroll to change adjust xbacklight." ;;
4) xbacklight -inc 10 ;;
5) xbacklight -dec 10 ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
6) setsid -f "$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

# If there is no battery attached
! [ -d /sys/class/power_supply/BAT? ] && printf "📛"

# Loop through all attached batteries.
for battery in /sys/class/power_supply/BAT?
do
# Get its remaining capacity and charge status.
capacity=$(cat "$battery"/capacity 2>/dev/null) || break
status=$(sed "s/[Dd]ischarging/🔋/;s/[Nn]ot charging/🛑/;s/[Cc]harging/🔌/;s/[Uu]nknown/♻/;s/[Ff]ull/⚡/" "$battery"/status)

# If it is discharging and 25% or less, we will add a ❗ as a warning.
[ "$capacity" -le 25 ] && [ "$status" = "🔋" ] && warn=""

printf "%s%s%s%s%% " "$status" "$warn" "$capacity"
unset warn
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" 2>&1)" in
"Full") status="" ;;
"Discharging") status="🔋 " ;;
"Charging") status="🔌" ;;
"Not charging") status="🛑 " ;;
"Unknown") status="♻️" ;;
*) exit 1 ;;
esac
capacity="$(cat "$battery/capacity" 2>&1)"
# 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 && printf "\\n"
42 changes: 30 additions & 12 deletions scripts/.local/bin/brightness
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
#!/bin/sh
# display current brightness
# Display current brightness

# get first two digits of brightness value
brightnum=$(xbacklight -get)
[[ "$brightnum" = "" ]] && echo "🚱" exit 1
brightness=$(printf "${brightnum%.*}")
# current brightness
curr_brightness=$(cat /sys/class/backlight/*/brightness)

if [[ "$brightness" -gt "70" ]]; then
echo "🌞$brightness"
elif [[ "$brightness" -le "10" ]]; then
echo "🌑$brightness"
elif [[ "$brightness" -lt "30" ]]; then
echo "🌦$brightness"
# max_brightness
max_brightness=$(cat /sys/class/backlight/*/max_brightness)

# brightness percentage
brightness_per=$((100 * curr_brightness / max_brightness))

case $BLOCK_BUTTON in
1)
;;
3)
notify-send "💡 Brightness module" "\- Shows current brightness level ☀️."
;;
6)
setsid -f "$TERMINAL" -e "$EDITOR" "$0"
;;
esac

# Assign emoji based on brightness
if [[ $brightness_per -ge 70 ]]; then
bright_icon="🌞"
elif [[ $brightness_per -ge 40 && $brightness_per -lt 70 ]]; then
bright_icon="🌤️"
elif [[ $brightness_per -ge 15 && $brightness_per -lt 40 ]]; then
bright_icon=""
else
echo "$brightness"
bright_icon="🌙"
fi

echo "${bright_icon} ${brightness_per}%"
8 changes: 4 additions & 4 deletions scripts/.local/bin/capslock
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/sh
# show if caps lock is on or off
# Show caps lock status

# caps lock status
# Get caps lock status
capslock=$(xset q | grep "Caps Lock:" | awk '{print $4}')

case $BLOCK_BUTTON in
1)
1)
pkill -RTMIN+26 "${STATUSBAR:-dwmblocks}";;
3) notify-send "Caps Lock indicator" "Caps Lock is currently $capslock" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

printf "🔒$capslock"
printf "🔒 $capslock"
8 changes: 0 additions & 8 deletions scripts/.local/bin/chardetect

This file was deleted.

11 changes: 2 additions & 9 deletions scripts/.local/bin/clock
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@ case "$clock" in
esac

case $BLOCK_BUTTON in
1)
notify-send "Current hour" "$(date '+%R:%S')"
notify-send "Today's date" "$(date '+%A, %d %B %Y')"
notify-send "Yesterday's date" "$(date '+%A %d %B %y' -d 'yesterday')"
notify-send "Tomorrow's date" "$(date '+%A %d %B %y' -d 'tomorrow')"
notify-send "This Month" "$(cal --color=never -mS)"
;;
1) notify-send "This Month" "$(cal | sed "s/\<$(date +'%e'|tr -d ' ')\>/<b><span color='red'>&<\/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" ;;
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

#echo " $(date '+%a %d %b %Y') $icon $(date '+%R')"
echo "📅 $(date '+%a %d/%m/%Y') $icon $(date '+%R')"
4 changes: 2 additions & 2 deletions scripts/.local/bin/cpu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ case $BLOCK_BUTTON in
3) notify-send "🖥 CPU module " "\- Shows CPU temperature.
- Click to show intensive processes.
- Middle click to open htop." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

printf "🌡$(sensors | grep "Core 0" | awk '{print $3}' | tr -d "+")"
sensors | awk '/Core 0/ {print "🌡 " $3}' | tr -d '+'
18 changes: 0 additions & 18 deletions scripts/.local/bin/emoji

This file was deleted.

22 changes: 11 additions & 11 deletions scripts/.local/bin/fanspeed
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
# get fan speed
# Get ThinkPad fan speed

speed=$(cat /proc/acpi/ibm/fan | grep level | head -n 1 | awk '{print $2}')
# Get fan speed
speed=$(cat /proc/acpi/ibm/fan | awk '/level:/ {print $2}')

printf "💨"
icon="💨"

if [ "$speed" = "auto" ]; then
printf " a"
else if [ "$speed" = "disengaged" ]; then
printf " max"
else
printf " $speed"
fi
fi
case $speed in
"auto") tspeed="auto" ;;
"disengaged") tspeed="max" ;;
*) tspeed="$speed" ;;
esac

echo "$icon $tspeed"
39 changes: 0 additions & 39 deletions scripts/.local/bin/forecast

This file was deleted.

25 changes: 17 additions & 8 deletions scripts/.local/bin/internet
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
#!/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
❌: wifi disabled
📡: no wifi connection
📶: wifi connection with quality
❎: no ethernet
🌐: ethernet working
🔒: vpn is active
" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
6) setsid -f "$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)" wifiname=$(iw dev wlp3s0 info | grep ssid | awk '{print $2}');;
up) wifiicon="$(awk '/^\s*w/ { print "📶 " }' /proc/net/wireless)" wifiname=$(iw dev wlp3s0 info | grep ssid | awk '{print $2}');;
esac
# Wifi
if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
# Chanhe
wifiname="📶 $(iw dev | awk '/ssid/ {print $2}')"
wifiicon="$wifiname $(awk '/^\s*w/ { print int($3 * 100 / 70) "% " }' /proc/net/wireless)"
elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
[ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="📡 " || wifiicon=""
fi

# Ethernet
[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐 " || ethericon=""

# TUN
[ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon=" 🔒"

printf "%s%s%s\n" "$wifiicon" "$wifiname " "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)"
printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"
16 changes: 0 additions & 16 deletions scripts/.local/bin/kbselect

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/.local/bin/memory
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

free --mega | sed -n '2{p;q}' | awk '{printf ("🖥%2.2fGB/%2.2fGB\n", ( $3 / 1000), ($2 / 1000))}'
free --mega | sed -n '2{p;q}' | awk '{printf ("🖥 %2.2fGB/%2.2fGB\n", ( $3 / 1000), ($2 / 1000))}'
33 changes: 0 additions & 33 deletions scripts/.local/bin/samloader

This file was deleted.

Loading

0 comments on commit 46c1bfc

Please sign in to comment.