Polybar scripts and config

This commit is contained in:
kittenlikeasmallcat 2022-08-05 18:11:21 +00:00 committed by GitHub
parent f094d49a22
commit fa108ee480
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 594 additions and 0 deletions

View file

@ -0,0 +1,129 @@
#!/bin/sh
battery_print() {
PATH_AC="/sys/class/power_supply/AC"
PATH_BATTERY_0="/sys/class/power_supply/BATA"
PATH_BATTERY_1="/sys/class/power_supply/BATB"
ac=0
battery_level_0=0
battery_level_1=0
battery_max_0=0
battery_max_1=0
charging=
if [ -f "$PATH_AC/online" ]; then
ac=$(cat "$PATH_AC/online")
fi
if [ -f "$PATH_BATTERY_0/energy_now" ]; then
battery_level_0=$(cat "$PATH_BATTERY_0/energy_now")
fi
if [ -f "$PATH_BATTERY_0/energy_full" ]; then
battery_max_0=$(cat "$PATH_BATTERY_0/energy_full")
fi
if [ -f "$PATH_BATTERY_1/energy_now" ]; then
battery_level_1=$(cat "$PATH_BATTERY_1/energy_now")
fi
if [ -f "$PATH_BATTERY_1/energy_full" ]; then
battery_max_1=$(cat "$PATH_BATTERY_1/energy_full")
fi
# battery_level_0=$(("$battery_level_0"))
# battery_level_1=$(("$battery_level_1"))
# battery_max_0=$(("$battery_max_0"))
# battery_max_1=$(("$battery_max_1"))
#
battery_percent_0=$(("$battery_level_0 * 100"))
if [ "$battery_percent_0" -gt 0 ]; then
battery_percent_0=$(("$battery_percent_0 / $battery_max_0"))
else
battery_percent_0="0"
fi
battery_percent_1=$(("$battery_level_1 * 100"))
if [ "$battery_percent_1" -gt 0 ]; then
battery_percent_1=$(("$battery_percent_1 / $battery_max_1"))
else
battery_percent_1="0"
fi
if [ "$ac" -eq 1 ]; then
icon=""
if [ "$battery_percent_0" -gt 95 ] && [ "$battery_percent_1" -gt 95 ]; then
echo "$icon"
else
for (( i=0; i<${#charging}; i++ )); do
echo -n "${charging:$i:1}$battery_percent_0%"
echo -n "|"
echo "${charging:$i:1}$battery_percent_1%"
sleep 1
done
fi
else
#elif [ "$ac" -lt 1 ]; then
if [ "$battery_percent_0" -gt 94 ]; then
icon0=""
elif [ "$battery_percent_0" -gt 85 ]; then
icon0=""
elif [ "$battery_percent_0" -gt 60 ]; then
icon0=""
elif [ "$battery_percent_0" -gt 35 ]; then
icon0=""
elif [ "$battery_percent_0" -gt 10 ]; then
icon0=""
elif [ "$battery_percent_1" -lt 10 ]; then
icon0=""
else
icon0=""
fi
if [ "$battery_percent_1" -gt 94 ]; then
icon1=""
elif [ "$battery_percent_1" -gt 85 ]; then
icon1=""
elif [ "$battery_percent_1" -gt 60 ]; then
icon1=""
elif [ "$battery_percent_1" -gt 35 ]; then
icon1=""
elif [ "$battery_percent_1" -gt 10 ]; then
icon1=""
elif [ "$battery_percent_1" -lt 10 ]; then
icon1=""
else
icon1=""
fi
echo "$icon0""$battery_percent_0%""|""$icon1""$battery_percent_1%"
fi
}
path_pid="/tmp/polybar-battery-combined-udev.pid"
case "$1" in
--update)
pid=$(cat $path_pid)
if [ "$pid" != "" ]; then
kill -10 "$pid"
fi
;;
*)
echo $$ > $path_pid
trap exit INT
trap "echo" USR1
while true; do
battery_print
sleep 1 &
wait
done
;;
esac

366
.config/polybar/config.ini Normal file
View file

@ -0,0 +1,366 @@
;=============================================================
; ██▓███ ▒█████ ██▓ ▓██ ██▓ ▄▄▄▄ ▄▄▄ ██▀███
;▓██░ ██▒▒██▒ ██▒▓██▒ ▒██ ██▒▓█████▄ ▒████▄ ▓██ ▒ ██▒
;▓██░ ██▓▒▒██░ ██▒▒██░ ▒██ ██░▒██▒ ▄██▒██ ▀█▄ ▓██ ░▄█ ▒
;▒██▄█▓▒ ▒▒██ ██░▒██░ ░ ▐██▓░▒██░█▀ ░██▄▄▄▄██ ▒██▀▀█▄
;▒██▒ ░ ░░ ████▓▒░░██████▒ ░ ██▒▓░░▓█ ▀█▓ ▓█ ▓██▒░██▓ ▒██▒
;▒▓▒░ ░ ░░ ▒░▒░▒░ ░ ▒░▓ ░ ██▒▒▒ ░▒▓███▀▒ ▒▒ ▓▒█░░ ▒▓ ░▒▓░
;░▒ ░ ░ ▒ ▒░ ░ ░ ▒ ░▓██ ░▒░ ▒░▒ ░ ▒ ▒▒ ░ ░▒ ░ ▒░
;░░ ░ ░ ░ ▒ ░ ░ ▒ ▒ ░░ ░ ░ ░ ▒ ░░ ░
; ░ ░ ░ ░░ ░ ░ ░ ░ ░
; ░ ░ ░
; https://github.com/polybar/polybar
;=============================================================
[colors]
background = #000000
background-alt = #1c2f2f
foreground = #587864
primary = #228b22
secondary = #2e8b57
alert = #3cb371
disabled = #556b2f
[bar/main]
#monitor = ${env:MONITOR:VGA1}
width = 100%
height = 12pt
radius = 0
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 3pt
border-size = 0pt
border-color = ${colors.background-alt}
padding-left = 1
padding-right = 1
module-margin = 1
font-0 = ProggyCleanTTSZ Nerd Font:size= 12
font-1 = Gohu Font Nerd Font:size= 7
;font-2 = ProggySmallTT:size= 9
modules-left= xworkspaces menu-apps nowplaying
modules-center=date
modules-right=pulseaudio memory cpu wireless-network temperature battery-combined-ramp-udev backlight info-redshift-temp 8ball
cursor-click = pointer
cursor-scroll = ns-resize
enable-ipc = true
; wm-restack = bspwm
; override-redirect = true
[bar/1]
monitor = ${env:MONITOR:VGA1}
width = 100%
height = 12pt
radius = 0
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 3pt
border-size = 0pt
border-color = ${colors.background-alt}
padding-left = 0
padding-right = 0
module-margin = 1
font-0 = ProggyCleanTTSZ Nerd Font:size= 12
font-1 = Gohu Font Nerd Font:size= 7
;font-2 = ProggySmallTT:size= 9
modules-left= xworkspaces menu-apps nowplaying
modules-center=date
modules-right=pulseaudio memory cpu wireless-network temperature battery-combined-ramp-udev backlight info-redshift-temp 8ball
cursor-click = pointer
cursor-scroll = ns-resize
enable-ipc = true
; wm-restack = bspwm
; override-redirect = true
[bar/2]
monitor = ${env:MONITOR:LVDS1}
width = 100%
height = 12pt
radius = 0
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 3pt
border-size = 0pt
border-color = ${colors.background-alt}
padding-left = 0
padding-right = 0
module-margin = 1
font-0 = ProggyCleanTTSZ Nerd Font:size= 12
font-1 = Gohu Font Nerd Font:size= 7
;font-2 = ProggySmallTT:size= 9
modules-left= xworkspaces nowplaying
modules-center=date
modules-right=pulseaudio backlight
cursor-click = pointer
cursor-scroll = ns-resize
enable-ipc = true
[module/xworkspaces]
type = internal/xworkspaces
label-active = %{O3}%name%%{O3}
label-active-background = ${colors.primary}
label-active-foreground = #000000
label-occupied = %{O3}%name%%{O2}
label-occupied-background = ${colors.background-alt}
label-occupied-foreground = #008000
label-urgent = %{O3}%name%%{O2}
label-urgent-background = ${colors.alert}
label-empty = %{O3}%name%%{O2}
label-empty-foreground = ${colors.disabled}
[module/hcbar]
type = custom/script
exec-if = ps -C herbstluftwm >/dev/null 2>&1
exec = /home/ktn/.config/polybar/hcbar
tail = true
[module/menu-apps]
type = custom/menu
expand-right = true
menu-0-0 =
menu-0-0-exec = firefox
menu-0-1 =
menu-0-1-exec = signal-desktop
menu-0-2 =
menu-0-2-exec = kcalc
menu-0-3 =
menu-0-3-exec = retroarch
menu-0-4 =
menu-0-4-exec = roxterm
menu-0-5 =
menu-0-5-exec = #menu-apps.open.1
menu-1-0 = Writer
menu-1-0-exec = libreoffice --writer
menu-1-1 = Impress
menu-1-1-exec = libreoffice --impress
menu-1-2 = Calc
menu-1-2-exec = libreoffice --calc
menu-0-6 =
menu-0-6-exec = #menu-apps.open.2
menu-2-0 = GIMP
menu-2-0-exec = gimp
menu-2-1 =feh
menu-2-1-exec = feh
menu-2-2 =XAOS
menu-2-2-exec = xaos
menu-0-7 =
menu-0-7-exec = #menu-apps.open.3
menu-3-0 = Clementine
menu-3-0-exec = clementine
menu-3-1 = EasyTAG
menu-3-1-exec = easytag
menu-3-2 = mpv
menu-3-2-exec = mpv --player-operation-mode=pseudo-gui -- %U
menu-3-3 = cmus
menu-3-3-exec = roxterm -p cmus
menu-0-8=
menu-0-8-exec = #menu-apps.open.4
menu-4-0 =
menu-4-0-exec = caja
menu-4-1 = Documents
menu-4-1-exec = caja ~/Documents
menu-4-2 = Music
menu-4-2-exec = caja ~/Music
menu-4-3 = Pictures
menu-4-3-exec = caja ~/Pictures
menu-4-4 = LocalBin
menu-4-4-exec = caja ~/.local/bin
menu-4-5 =
menu-4-5-exec = timeshift-launcher
menu-0-9 =
menu-0-9-exec = #menu-apps.open.5
menu-5-0 = ROFI
menu-5-0-exec = xed ~/.config/rofi/config.rasi
menu-5-1 = SXHKDRC
menu-5-1-exec = xed ~/.config/dk/sxhkrc
menu-5-2 = POLYBAR
menu-5-2-exec = xed ~/.config/polybar/config.ini
menu-5-3 = HLWM
menu-5-3-exec = xed ~/.config/herbstluftwm/autostart
menu-5-4 = CONF
menu-6-4-exec = caja ~/.config/
menu-5-5 =
menu-5-5-exec = #menu-apps.open.6
menu-6-0 = Grubedit
menu-6-0-exec = grub-customizer
menu-6-1 = dconf
menu-6-1-exec = dconf-editor
menu-6-2 =
menu-6-2-exec = #menu-apps.open.7
menu-7-0 = Xscreensaving
menu-7-0-exec = xscreensaver-settings
menu-7-1 = Lightdm
menu-7-1-exec = lightdm-gtk-greeter-settings-pkexec
menu-6-3 =
menu-6-3-exec = #menu-apps.open.8
menu-8-0 =Gdisks
menu-8-0-exec = gnome-disks
menu-8-1 =Gparted
menu-8-1-exec = gparted
menu-0-10 =
menu-0-10-exec = #menu-apps.open.9
menu-9-0 =
menu-9-0-exec = sudo /sbin/shutdown -h now
menu-9-1 =
menu-9-1-exec = sudo /sbin/reboot
menu-9-2 =
menu-9-2-exec = herbstclient quit
menu-0-11 =
menu-0-11-exec = kdeconnect-settings
label-open = %{O-10}
label-close = %{O-10}
label-separator =
label-seperator-foreground = ${colors.primary}
label-foreground = ${colors.foreground}
label-menu-font = 2
[module/nowplaying]
type = custom/script
exec = nowplaying | head -c 71
click-left = wmctrl -a CMUS || $(echo "$(nowplaying)")
label = %{O-7}%output%
format = %{T2}<label>
label-foreground = ${colors.alert}
tail = true
interval = 10
[module/date]
type = internal/date
interval = 1
date = %a/%D卑%l:%M%p
date-alt = %b %j/365 %s %Z
label = %{R}%date%%{R}
label-foreground = ${colors.primary}
label-underline = #000000
[module/pulseaudio]
type = internal/pulseaudio
sink = alsa_output.pci-0000_12_00.3.analog-stereo
use-ui-max = true
interval = 5
format-volume = <label-volume><bar-volume>%{O-4}
label-volume = "%decibels%dB"
label-muted = ||||
label-volume-foreground = ${colors.primary}
bar-volume-width = 5
bar-volume-foreground-0 = ${colors.disabled}
bar-volume-indicator =
bar-volume-indicator-foreground = ${colors.alert}
bar-volume-empty = %{A1:pactl set-sink-volume @DEFAULT_SINK@ +10%: A6:pactl set-sink-volume @DEFAULT_SINK@ +30%:}|%{A}%{A}
bar-volume-empty-foreground = ${colors.background-alt}
bar-volume-fill = %{A1:pactl set-sink-volume @DEFAULT_SINK@ -10%: A6:pactl set-sink-volume @DEFAULT_SINK@ -30%:}|%{A}%{A}
click-right = pavucontrol
[module/memory]
type = internal/memory
interval = 2
format-prefix = ""
format-prefix-foreground = ${colors.primary}
label = %percentage_used:3:3%%|
click-right = exec roxterm --profile btop
[module/cpu]
type = internal/cpu
interval = 3
format = %{O-10}<label>
format-foreground = ${colors.primary}
label = %{O-4}%{F#587864}%percentage-sum:3:3%%
[module/phone-ticker]
type = custom/script
exec = ~/.config/polybar/kdeconnectscripts/phone-ticker.sh
label-font=1
#label-maxlen = 15
click-left = ~/.config/polybar/kdeconnectscripts/phone-reply.sh
click-right = ~/.config/polybar/kdeconnectscripts/phone-dismiss.sh
label = %output%
intervall = 5
format-foreground = #959595
format-background = ${colors.background-alt}
[module/wireless-network]
type = internal/network
interface = wlan0
interval = 3.0
unknown-as-up = true
format-connected-background = ${colors.background}
format-connected-foreground = ${colors.foreground}
label-connected ="直"
format-connected = %{A1:connman-gtk --no-icon:}<label-connected><ramp-signal>%{A}%{O-3}
format-disconnected-background = ${colors.background}
format-disconnected-foreground = ${colors.disabled}
format-disconnected = %{A2:connman-gtk --no-icon:}<label-disconnected>%{A}%{O-3}
label-disconnected =%{A1:togglewifi.sh:}睊||%{A}
prefix-connected = "直"
ramp-signal-0 = ""
ramp-signal-1 = "|"
ramp-signal-foreground = ${colors.foreground}
label-connected-foreground = ${colors.primary}
[module/wired-network]
type = internal/network
interface = eth0
interval = 3.0
format-connected-background = ${colors.background}
format-connected-foreground = ${colors.foreground}
format-connected = <label-connected>
label-connected = ""
format-disconnected-background = ${colors.background}
format-disconnected-foreground = ${colors.disabled}
format-disconnected = <label-disconnected>
label-disconnected =""
[module/temperature]
type = internal/temperature
format = %{O-5}<label>%{O-5}
thermal-zone = 1
base-temperature = 20
label = %temperature-c%
label-foreground = ${colors.foreground}
format-warn = <label-warn>%{O-5}
warn-temperature = 80
label-warn = %temperature-c%
label-warn-foreground = ${colors.alert}
label-warn-background = ${colors.background-alt}
[module/battery-combined-ramp-udev]
type = custom/script
exec = ~/.config/polybar/battery-combined-ramp-udev.sh
tail = true
click-right = roxterm -p powertop --role=splash
[module/backlight]
type = custom/script
exec = ~/.config/polybar/light-polybar
click-left = light -A 4
click-right = light -U 4
double-click-right = light -T .3
double-click-left = light -T 3
format-foreground = ${colors.primary}
[module/info-redshift-temp]
type = custom/script
exec = ~/.config/polybar/redshift.sh
interval = 5
click-left = exec redshift
click-right = killall redshift
[module/8ball]
type = custom/text
;content = ﱬ
content =%{O-10} %{O-9}%{T2}8
format =<content>
click-left = roxterm -p 8ball --role=splash
[settings]
screenchange-reload = true
pseudo-transparency = false
; vim:ft=dosini

View file

@ -0,0 +1,61 @@
#!/usr/bin/env bash
#[module/info-hlwm-workspaces]
#type = custom/script
#exec = ~/.config/polybar/info-hlwm-workspaces.sh
#exec-if = ps -C herbstluftwm >/dev/null 2>&1
#tail = true
#scroll-up = herbstclient use_index -1 --skip-visible &
#scroll-down = herbstclient use_index +1 --skip-visible &
#label-active-font=1
#
herbstclient --idle "tag_*" 2>/dev/null | {
while true; do
# Read tags into $tags as array
IFS=$'\t' read -ra tags <<< "$(herbstclient tag_status)"
{
for i in "${tags[@]}" ; do
# Read the prefix from each tag and render them according to that prefix
case ${i:0:1} in
'#')
# the tag is viewed on the focused monitor
# TODO Add your formatting tags for focused workspaces
echo "%{F#000}%{B#F27127}%{U#F28D35}" # Add your formatting tags for empty workspaces
;;
':')
# : the tag is not empty
# TODO Add your formatting tags for occupied workspaces
echo "%{F#000}%{B#BFB8AA}" # Add your formatting tags for empty workspaces
;;
'!')
# ! the tag contains an urgent window
# TODO Add your formatting tags for workspaces with the urgent hint
;;
'-')
# - the tag is viewed on a monitor that is not focused
# TODO Add your formatting tags for visible but not focused workspaces
echo "%{F-}%{B#764E29}" # Add your formatting tags for empty workspaces
;;
*)
# . the tag is empty
# There are also other possible prefixes but they won't appear here
echo "%{F-}%{B-}" # Add your formatting tags for empty workspaces
;;
esac
echo "%{A1:herbstclient use ${i:1}:} ${i:1} %{A -u -o F- B-}"
done
echo "%{F-}%{B-}"
} | tr -d "\n"
echo
# wait for next event from herbstclient --idle
read -r || break
done
} 2>/dev/null

View file

@ -0,0 +1,16 @@
#!/bin/sh
LIGHT=$( light|head -c 1 )
if [ $LIGHT = 1 ]; then
ICON="⏽⏽⏽"
elif [ $LIGHT -gt 8 ]; then
ICON="⏽⏽⏽"
elif [ $LIGHT -gt 6 ]; then
ICON="⏽⏽|"
elif [ $LIGHT -gt 4 ]; then
ICON="⏽||"
elif [ $LIGHT -gt 1 ]; then
ICON="|||"
else
ICON="Xxxx"
fi
echo %{O-7}$ICON%{O-8}

View file

@ -0,0 +1,7 @@
#!/bin/sh
if [ "$(pgrep -x redshift)" ]; then
echo "%{F#056405}"
else
echo "%{F#056405}"
fi

View file

@ -0,0 +1,15 @@
#!/bin/bash
wmctrl -a $(echo "$(nowplaying)")
#
#if $(pgrep -x "spotify" >/dev/null) ; then
#dkcmd win "spotify" focus;
#wmctrl -a $(echo "$(nowplaying)";fi
#
#if $(pgrep -x "clementine" >/dev/null); then
#dkcmd win "clementine" focus;
#wmctrl -a $(echo "$(nowplaying)";fi
#
#if $(pgrep -x "cmus" >/dev/null); then
#dkcmd win "cmus" focus;
#wmctrl -a $(echo "$(nowplaying)" ;fi