Add polybar
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
;==========================================================
|
||||
;
|
||||
;
|
||||
; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗
|
||||
; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗
|
||||
; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝
|
||||
; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗
|
||||
; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║
|
||||
; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
|
||||
;
|
||||
;
|
||||
; To learn more about how to configure Polybar
|
||||
; go to https://github.com/polybar/polybar
|
||||
;
|
||||
; The README contains a lot of information
|
||||
;
|
||||
;==========================================================
|
||||
|
||||
[colors]
|
||||
background = #052335
|
||||
foreground = #71acd0
|
||||
sep = #7ad
|
||||
module-label = #ffff00
|
||||
module-value = #ffffff
|
||||
occupied-tag-background = #020c12
|
||||
active-tag-background = #b04d12
|
||||
tag-foreground = #ffffff
|
||||
|
||||
[bar/mybar]
|
||||
width = 100%
|
||||
height = 2%
|
||||
radius = 1
|
||||
top = true
|
||||
|
||||
; dpi = 96
|
||||
|
||||
background = ${colors.background}
|
||||
foreground = ${colors.foreground}
|
||||
|
||||
line-size = 1pt
|
||||
|
||||
border-size = 0pt
|
||||
border-color = #000000ff
|
||||
|
||||
padding-left = 1
|
||||
padding-right = 1
|
||||
|
||||
module-margin = 1
|
||||
font-0 = monospace:size=8;1"
|
||||
|
||||
modules-left = xworkspaces
|
||||
modules-right = ups-label ups sep memory-label memory sep cpu-label cpu cpu-temp sep gpu-label gpu-temp sep vol-label pulseaudio sep net-label wlan txrx sep bt-label bt sep date
|
||||
|
||||
cursor-click = pointer
|
||||
cursor-scroll = ns-resize
|
||||
|
||||
enable-ipc = true
|
||||
|
||||
[module/cpu-label]
|
||||
type = "custom/text"
|
||||
content = "C"
|
||||
content-padding = 0
|
||||
|
||||
[module/memory-label]
|
||||
type = "custom/text"
|
||||
content = "R"
|
||||
content-padding = 0
|
||||
|
||||
[module/gpu-label]
|
||||
type = "custom/text"
|
||||
content = "G"
|
||||
content-padding = 0
|
||||
|
||||
[module/ups-label]
|
||||
type = "custom/text"
|
||||
content = "U"
|
||||
content-padding = 0
|
||||
|
||||
[module/vol-label]
|
||||
type = "custom/text"
|
||||
content = "V"
|
||||
content-padding = 0
|
||||
|
||||
[module/net-label]
|
||||
type = "custom/text"
|
||||
content = "NT"
|
||||
content-padding = 0
|
||||
|
||||
[module/bt-label]
|
||||
type = "custom/text"
|
||||
content = "BT"
|
||||
content-padding = 0
|
||||
|
||||
[module/sep]
|
||||
type = "custom/text"
|
||||
content = "|"
|
||||
content-padding = 0
|
||||
content-foreground = ${colors.sep}
|
||||
|
||||
[module/cpu-temp]
|
||||
type = custom/script
|
||||
exec = hmon cpu
|
||||
interval = 10
|
||||
label = "%output%"
|
||||
label-foreground = ${colors.module-value}
|
||||
|
||||
[module/gpu-temp]
|
||||
type = custom/script
|
||||
exec = hmon gpu
|
||||
interval = 10
|
||||
label = "%output%"
|
||||
label-foreground = ${colors.module-value}
|
||||
|
||||
[module/ups]
|
||||
type = custom/script
|
||||
exec = apcaccess -u -p LOADPCT
|
||||
interval = 15
|
||||
label = "%output:3%%"
|
||||
label-foreground = ${colors.module-value}
|
||||
|
||||
[module/xworkspaces]
|
||||
type = internal/xworkspaces
|
||||
|
||||
label-active = %name%
|
||||
label-active-foreground = ${colors.tag-foreground}
|
||||
label-active-background = ${colors.active-tag-background}
|
||||
label-active-padding = 2
|
||||
|
||||
label-occupied = %name%
|
||||
label-occupied-background = ${colors.occupied-tag-background}
|
||||
label-occupied-padding = 2
|
||||
|
||||
label-empty = %name%
|
||||
label-empty-padding = 2
|
||||
|
||||
[module/pulseaudio]
|
||||
type = internal/pulseaudio
|
||||
|
||||
label-volume = %percentage%
|
||||
label-volume-foreground = ${colors.module-value}
|
||||
|
||||
label-muted = muted
|
||||
label-muted-foreground = ${colors.foreground}
|
||||
|
||||
[module/memory]
|
||||
type = internal/memory
|
||||
interval = 2
|
||||
label = %percentage_used:2%%
|
||||
label-foreground = ${colors.module-value}
|
||||
|
||||
[module/cpu]
|
||||
type = internal/cpu
|
||||
interval = 2
|
||||
label = %percentage:2%%
|
||||
label-foreground = ${colors.module-value}
|
||||
|
||||
[network-base]
|
||||
type = internal/network
|
||||
interval = 5
|
||||
format-connected = <label-connected>
|
||||
format-disconnected = <label-disconnected>
|
||||
label-disconnected = dc
|
||||
|
||||
[module/wlan]
|
||||
inherit = network-base
|
||||
interface-type = wireless
|
||||
label-connected = %essid%
|
||||
label-connected-foreground=${colors.module-value}
|
||||
|
||||
[module/eth]
|
||||
inherit = network-base
|
||||
interface-type = wired
|
||||
label-connected = %{F#F0C674}%ifname%%{F-} %local_ip%
|
||||
|
||||
[module/txrx]
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/polybar-scripts/polybar-scripts/network-traffic/network-traffic.sh
|
||||
tail = true
|
||||
label-foreground = ${colors.module-value}
|
||||
|
||||
[module/bt]
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/polybar-scripts/polybar-scripts/system-bluetooth-bluetoothctl/system-bluetooth-bluetoothctl.sh
|
||||
tail = true
|
||||
label-foreground = ${colors.module-value}
|
||||
|
||||
[module/date]
|
||||
type = internal/date
|
||||
interval = 1
|
||||
date = %m-%d %H:%M
|
||||
label = %date%
|
||||
label-foreground = ${colors.foreground}
|
||||
|
||||
[settings]
|
||||
screenchange-reload = true
|
||||
pseudo-transparency = false
|
||||
|
||||
; vim:ft=dosini
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_bytes() {
|
||||
if [ "$1" -eq 0 ] || [ "$1" -lt 1000 ]; then
|
||||
bytes="0 kB/s"
|
||||
elif [ "$1" -lt 1000000 ]; then
|
||||
bytes="$(echo "$1/1000" | bc -l | LANG=C xargs printf "%.f\n") kB/s"
|
||||
else
|
||||
bytes="$(echo "$1/1000000" | bc -l | LANG=C xargs printf "%.1f\n") MB/s"
|
||||
fi
|
||||
|
||||
echo "$bytes"
|
||||
}
|
||||
|
||||
print_bytes_v2() {
|
||||
if [ "$1" -eq 0 ] || [ "$1" -lt 1000 ]; then
|
||||
bytes="0"
|
||||
elif [ "$1" -lt 1000000 ]; then
|
||||
bytes="$(echo "$1/1000" | bc -l | LANG=C xargs printf "%.f\n") k"
|
||||
else
|
||||
bytes="$(echo "$1/1000000" | bc -l | LANG=C xargs printf "%.1f\n") M"
|
||||
fi
|
||||
|
||||
echo "$bytes"
|
||||
}
|
||||
|
||||
print_bit() {
|
||||
if [ "$1" -eq 0 ] || [ "$1" -lt 10 ]; then
|
||||
bit="0 B"
|
||||
elif [ "$1" -lt 100 ]; then
|
||||
bit="$(echo "$1*8" | bc -l | LANG=C xargs printf "%.f\n") B"
|
||||
elif [ "$1" -lt 100000 ]; then
|
||||
bit="$(echo "$1*8/1000" | bc -l | LANG=C xargs printf "%.f\n") K"
|
||||
else
|
||||
bit="$(echo "$1*8/1000000" | bc -l | LANG=C xargs printf "%.1f\n") M"
|
||||
fi
|
||||
|
||||
echo "$bit"
|
||||
}
|
||||
|
||||
INTERVAL=3
|
||||
INTERFACES="wlan0"
|
||||
|
||||
declare -A bytes
|
||||
|
||||
for interface in $INTERFACES; do
|
||||
bytes[past_rx_$interface]="$(cat /sys/class/net/"$interface"/statistics/rx_bytes)"
|
||||
bytes[past_tx_$interface]="$(cat /sys/class/net/"$interface"/statistics/tx_bytes)"
|
||||
done
|
||||
|
||||
while true; do
|
||||
down=0
|
||||
up=0
|
||||
|
||||
for interface in $INTERFACES; do
|
||||
bytes[now_rx_$interface]="$(cat /sys/class/net/"$interface"/statistics/rx_bytes)"
|
||||
bytes[now_tx_$interface]="$(cat /sys/class/net/"$interface"/statistics/tx_bytes)"
|
||||
|
||||
bytes_down=$(((${bytes[now_rx_$interface]} - ${bytes[past_rx_$interface]}) / INTERVAL))
|
||||
bytes_up=$(((${bytes[now_tx_$interface]} - ${bytes[past_tx_$interface]}) / INTERVAL))
|
||||
|
||||
down=$(( "$down" + "$bytes_down" ))
|
||||
up=$(( "$up" + "$bytes_up" ))
|
||||
|
||||
bytes[past_rx_$interface]=${bytes[now_rx_$interface]}
|
||||
bytes[past_tx_$interface]=${bytes[now_tx_$interface]}
|
||||
done
|
||||
|
||||
# echo "Download: $(print_bytes $down) / Upload: $(print_bytes $up)"
|
||||
echo "$(print_bytes_v2 $down) / $(print_bytes_v2 $up)"
|
||||
# echo "Download: $(print_bit $down) / Upload: $(print_bit $up)"
|
||||
|
||||
sleep $INTERVAL
|
||||
done
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
bluetooth_print() {
|
||||
bluetoothctl | grep --line-buffered 'Device\|#' | while read -r REPLY; do
|
||||
if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then
|
||||
printf '#1'
|
||||
|
||||
devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2)
|
||||
counter=0
|
||||
|
||||
for device in $devices_paired; do
|
||||
device_info=$(bluetoothctl info "$device")
|
||||
|
||||
if echo "$device_info" | grep -q "Connected: yes"; then
|
||||
device_output=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-)
|
||||
device_battery_percent=$(echo "$device_info" | grep "Battery Percentage" | awk -F'[()]' '{print $2}')
|
||||
|
||||
if [ -n "$device_battery_percent" ]; then
|
||||
if [ "$device_battery_percent" -gt 90 ]; then
|
||||
device_battery_icon="#25"
|
||||
elif [ "$device_battery_percent" -gt 60 ]; then
|
||||
device_battery_icon="#24"
|
||||
elif [ "$device_battery_percent" -gt 35 ]; then
|
||||
device_battery_icon="#23"
|
||||
elif [ "$device_battery_percent" -gt 10 ]; then
|
||||
device_battery_icon="#22"
|
||||
else
|
||||
device_battery_icon="#21"
|
||||
fi
|
||||
|
||||
device_output="$device_output $device_battery_icon $device_battery_percent%"
|
||||
fi
|
||||
|
||||
if [ $counter -gt 0 ]; then
|
||||
printf ", %s" "$device_output"
|
||||
else
|
||||
printf " %s" "$device_output"
|
||||
fi
|
||||
|
||||
counter=$((counter + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
printf '\n'
|
||||
else
|
||||
echo "#2"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
bluetooth_toggle() {
|
||||
if bluetoothctl show | grep -q "Powered: no"; then
|
||||
bluetoothctl power on >> /dev/null
|
||||
sleep 1
|
||||
|
||||
devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2)
|
||||
echo "$devices_paired" | while read -r line; do
|
||||
bluetoothctl connect "$line" >> /dev/null
|
||||
done
|
||||
else
|
||||
devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2)
|
||||
echo "$devices_paired" | while read -r line; do
|
||||
bluetoothctl disconnect "$line" >> /dev/null
|
||||
done
|
||||
|
||||
bluetoothctl power off >> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--toggle)
|
||||
bluetooth_toggle
|
||||
;;
|
||||
*)
|
||||
bluetooth_print
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user