cleanup polybar scripts

main
Guus van Meerveld 11 months ago
parent cd5f1d2a53
commit 92888a1086

@ -21,14 +21,14 @@ include-directory = ~/.config/polybar/modules
[colors]
transparent = #00000000
background = #303030
background-alt = #282828
background = #212121
foreground = #dfdfdf
foreground-alt = #bbb
primary = #d32f2f
secondary = #1976d2
tertiary = #2e7d32
foreground-primary = #57b2ff
primary = #191919
secondary = #161616
tertiary = #131313
alert = #bd2c40
[constants]
@ -60,7 +60,7 @@ module-margin-left = 2
modules-left = bspwm
modules-center = title
modules-right = phone-battery temperature memory cpu audio battery wireguard wlan eth date
modules-right = audio phone-battery memory cpu battery wlan eth date
wm-restack = bspwm

@ -0,0 +1,26 @@
[module/battery]
type = internal/battery
battery = BAT1
adapter = ACAD
full-at = 100
format-charging = <label-charging>
format-discharging = <ramp-capacity> <label-discharging>
label-charging =  %percentage%%
label-discharging = %percentage%%
ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 
ramp-capacity-5 = 
ramp-capacity-6 = 
ramp-capacity-7 = 
ramp-capacity-8 = 
ramp-capacity-9 = 
ramp-capacity-10 = 

@ -0,0 +1,11 @@
[module/date]
type = internal/date
interval = 5
time = %H:%M
date = %a %e %b
label = %date% %time%
format =  <label>

@ -0,0 +1,23 @@
[module/wlan]
type = internal/network
interface-typed = wireless
interval = 3.0
format-connected = <label-connected>
label-connected =  %essid%
format-disconnected = <label-disconnected>
label-disconnected = 
[module/eth]
type = internal/network
interface-type = wired
interval = 3.0
label-connected = %downspeed%
format-connected =  <label-connected>
label-disconnected =

@ -1,3 +0,0 @@
[module/powermenu]
type = custom/script
exec = echo ''

@ -0,0 +1,13 @@
[module/phone-battery]
type = custom/script
exec = ~/.config/polybar/scripts/phone-battery
exec-if = ~/.config/polybar/scripts/phone-is-connected
format =  <label>
interval = 300

@ -1,96 +0,0 @@
[module/battery]
type = internal/battery
battery = BAT1
adapter = ACAD
full-at = 100
format-charging = <label-charging>
format-discharging = <ramp-capacity> <label-discharging>
label-charging =  %percentage%%
label-discharging = %percentage%%
ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 
ramp-capacity-5 = 
ramp-capacity-6 = 
ramp-capacity-7 = 
ramp-capacity-8 = 
ramp-capacity-9 = 
ramp-capacity-10 = 
[module/title]
type = internal/xwindow
label-maxlen = 50
[module/temperature]
type = internal/temperature
; for i in /sys/class/thermal/thermal_zone*; do echo "$i: $(<$i/type)"; done
thermal-zone = /sys/class/thermal/thermal_zone0
hwmon-path = /sys/devices/pci0000:00/0000:00:01.1/0000:10:00.0/hwmon/hwmon2/temp1_input
; for i in /sys/class/hwmon/hwmon*/temp*_input; do echo "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)"; done
format = <label>
label = %temperature-c%
[module/wlan]
type = internal/network
interface = wlp1s0
interval = 3.0
format-connected = <label-connected>
label-connected =  %essid%
format-disconnected = <label-disconnected>
label-disconnected = 
[module/wireguard]
type = custom/script
exec = ~/.config/polybar/wireguard-is-connected.sh
click-left = ~/.config/polybar/toggle-wireguard.sh
interval = 5
[module/eth]
type = internal/network
interface = enp34s0
interval = 3.0
label-connected =  %downspeed%
format-connected = <label-connected>
label-disconnected =
[module/phone-battery]
type = custom/script
exec = echo " $(mconnectctl show-battery /org/mconnect/device/2 | head -1 | awk '{print $2}')%"
exec-if = ~/.config/polybar/phone-is-connected.sh
interval = 300
[module/date]
type = internal/date
interval = 5
time = %H:%M
date = %a %e %b
label = %date% %time%
format =  <label>

@ -25,11 +25,11 @@ format-volume = <label-volume> <bar-volume>
label-volume = 
bar-volume-width = 10
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-0 = #57b2ff
bar-volume-foreground-1 = #57b2ff
bar-volume-foreground-2 = #57b2ff
bar-volume-foreground-3 = #57b2ff
bar-volume-foreground-4 = #57b2ff
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
@ -46,14 +46,10 @@ click-right = pavucontrol
type = internal/cpu
interval = 2
format-background = ${colors.background}
label = %percentage:2%%
[module/memory]
type = internal/memory
interval = 2
format-background = ${colors.background}
label = %percentage_used%%

@ -0,0 +1,12 @@
[module/temperature]
type = internal/temperature
; for i in /sys/class/thermal/thermal_zone*; do echo "$i: $(<$i/type)"; done
thermal-zone = /sys/class/thermal/thermal_zone0
; for i in /sys/class/hwmon/hwmon*/temp*_input; do echo "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)"; done
hwmon-path = /sys/devices/pci0000:00/0000:00:01.1/0000:10:00.0/hwmon/hwmon2/temp1_input
format = <label>
label = %temperature-c%

@ -0,0 +1,3 @@
[module/title]
type = internal/xwindow
label-maxlen = 50

@ -0,0 +1,8 @@
[module/wireguard]
type = custom/script
exec = ~/.config/polybar/scripts/wireguard-is-connected
click-left = ~/.config/polybar/scripts/toggle-wireguard
interval = 5

@ -5,11 +5,11 @@ padding = 3
type = internal/bspwm
label-focused = %index%
label-focused-background = ${colors.background-alt}
label-focused-underline = ${colors.primary}
label-focused-background = ${colors.secondary}
label-focused-padding = ${constants.padding}
label-occupied = %index%
label-occupied-background = ${colors.primary}
label-occupied-padding = ${constants.padding}
label-urgent = %index%!
@ -18,4 +18,5 @@ label-urgent-padding = ${constants.padding}
label-empty = %index%
label-empty-foreground = ${colors.foreground-alt}
; label-empty-background = ${colors.secondary}
label-empty-padding = ${constants.padding}

@ -1,7 +0,0 @@
#!/bin/bash
connected="$(mconnectctl show-device /org/mconnect/device/2 | sed -n 9,9p | awk '{print $2}')"
if [[ $connected == "false" ]]; then
exit 1
fi

@ -1,105 +0,0 @@
* {
accent: #d32f2f;
background: #303030;
background-text: #00000000;
background-alt: #282828;
foreground: #eeeeee;
foreground-alt: #dedede;
on: #66bb6a;
off: #ef5350;
}
* {
/* General */
option-6-listview-spacing: 6px;
menu-window-padding: 5px 5px;
menu-element-padding: 3px 0px -3px 3px;
}
#window {
width: 2.8%;
height: 23.7%;
anchor: east;
location: east;
x-offset: -10px;
y-offset: 0%;
border: 0px;
border-radius: 5px;
}
* {
background-color: @background;
text-color: @foreground;
font: @icon-font;
}
#horibox {
children: [ listview ];
}
#listview {
cycle: false;
spacing: 2.5%;
dynamic: true;
layout: vertical;
}
#element {
orientation: horizontal;
border: 0px;
border-radius: 100%;
background-color: @background-alt;
}
element-text{
background-color: @background-text;
text-color: inherit;
font: "Material Icons 32";
margin: -3px -5px 3px -3px;
}
element.selected {
background-color: @accent;
text-color: @foreground-alt;
}
* {
font: @text-font;
}
#window {
padding: @menu-window-padding;
children: [ horibox ];
}
listview {
spacing: @option-6-listview-spacing;
lines: 6;
}
element {
font: @icon-font;
border: @menu-element-border;
padding: @menu-element-padding;
border-color: @background-alt;
}
element.active,
element.selected.urgent {
background-color: @off;
text-color: @foreground-alt;
border-color: @on;
}
element.selected.urgent {
border-color: @accent;
text-color: @foreground-alt;
}
element.urgent,
element.selected.active {
background-color: @off;
border-color: @accent;
text-color: @foreground-alt;
}

@ -1,50 +0,0 @@
#!/bin/bash
# The name of polybar bar which houses the main spotify module and the control modules.
PARENT_BAR="now-playing"
PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
# Set the source audio player here.
# Players supporting the MPRIS spec are supported.
# Examples: spotify, vlc, chrome, mpv and others.
# Use `playerctld` to always detect the latest player.
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
PLAYER="spotify"
# Format of the information displayed
# Eg. {{ artist }} - {{ album }} - {{ title }}
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
FORMAT="{{ title }} - {{ artist }}"
# Sends $2 as message to all polybar PIDs that are part of $1
update_hooks() {
while IFS= read -r id
do
polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1
done < <(echo "$1")
}
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
STATUS=$PLAYERCTL_STATUS
else
STATUS="No player is running"
fi
if [ "$1" == "--status" ]; then
echo "$STATUS"
else
if [ "$STATUS" = "Stopped" ]; then
echo "No music is playing"
elif [ "$STATUS" = "Paused" ]; then
update_hooks "$PARENT_BAR_PID" 2
playerctl --player=$PLAYER metadata --format "$FORMAT"
elif [ "$STATUS" = "No player is running" ]; then
echo "$STATUS"
else
update_hooks "$PARENT_BAR_PID" 1
playerctl --player=$PLAYER metadata --format "$FORMAT"
fi
fi

@ -0,0 +1,5 @@
#!/bin/bash
device=$(~/.config/polybar/scripts/phone-path)
echo $(mconnectctl show-battery $device | head -1 | awk '{print $2}')%

@ -0,0 +1,9 @@
#!/bin/bash
device=$(~/.config/polybar/scripts/phone-path)
connected="$(mconnectctl show-device $device | sed -n 9,9p | awk '{print $2}')"
if [[ $connected == "false" ]]; then
exit 1
fi

@ -0,0 +1,5 @@
#!/bin/bash
device_number=1
echo $(mconnectctl list-devices | sed -n '2 p' | awk -v N=$device_number '{print $N}')

@ -1,51 +0,0 @@
#!/usr/bin/env bash
## Author : Aditya Shakya (adi1090x)
## Mail : adi1090x@gmail.com
## Github : @adi1090x
## Reddit : @adi1090x
rofi_command="rofi -theme $HOME/.config/polybar/scripts/color.rasi"
# Options
shutdown=""
reboot="󰜉"
lock="󰤁"
suspend="󰤄"
logout="󰿅"
# Variable passed to rofi
options="$shutdown\n$reboot\n$lock\n$suspend\n$logout"
# Remapping movement
xmodmap -e "keycode 32 = Return"
xmodmap -e "keycode 44 = Down"
xmodmap -e "keycode 45 = Up"
chosen="$(echo -e "$options" | $rofi_command -dmenu -selected-row 2)"
# Reset Remapping
xmodmap -e "keycode 32 = o"
xmodmap -e "keycode 44 = j"
xmodmap -e "keycode 45 = k"
case $chosen in
$shutdown)
systemctl poweroff
;;
$reboot)
systemctl reboot
;;
$lock)
betterlockscreen -l &
;;
$suspend)
amixer set Master mute
betterlockscreen -l &
sleep 0.5
systemctl suspend
;;
$logout)
bspc quit
;;
esac

@ -1,12 +0,0 @@
#!/bin/bash
# see man zscroll for documentation of the following parameters
zscroll -l 30 \
--delay 0.1 \
--scroll-padding "  " \
--match-command "`dirname $0`/get_spotify_status.sh --status" \
--match-text "Playing" "--scroll 1" \
--match-text "Paused" "--scroll 0" \
--update-check true "`dirname $0`/get_spotify_status.sh" &
wait