feat: polybar and rofi

This commit is contained in:
Elias Renman
2024-02-02 15:22:58 +01:00
parent 8d5b668ac4
commit d6cde2b388
17 changed files with 820 additions and 64 deletions

11
polybar/bluetooth.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
then
echo "󰂲"
else
if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ]
then
echo "󰥰"
fi
echo ""
fi

View File

@@ -0,0 +1,7 @@
#!/bin/sh
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
then
bluetoothctl power on
else
bluetoothctl power off
fi

View File

@@ -17,20 +17,19 @@
;==========================================================
[colors]
background = #282A2E
background-alt = #373B41
foreground = #C5C8C6
primary = #F0C674
secondary = #8ABEB7
alert = #A54242
disabled = #707880
background = #24283b
background-alt = #292e42
foreground = #c0caf5
primary = #bb9af7
secondary = #ff007c
alert = #db4b4b
disabled = #565f89
[bar/example]
monitor=${env:MONITOR:}
width = 100%
height = 24pt
radius = 6
; dpi = 96
background = ${colors.background}
@@ -41,18 +40,18 @@ line-size = 3pt
border-size = 4pt
border-color = #00000000
padding-left = 0
padding-right = 1
padding-left = 2
padding-right = 2
module-margin = 1
separator = |
separator =
separator-foreground = ${colors.disabled}
font-0 = monospace;2
modules-left = xworkspaces xwindow
modules-right = filesystem pulseaudio xkeyboard memory cpu wlan eth date
font-0 = JetbrainsMonoNerdFont;2
fixed-center = true
modules-left = power-button xworkspaces xwindow
modules-center = date time
modules-right = pulseaudio-devices wlan eth bluetooth memory cpu battery weather
cursor-click = pointer
cursor-scroll = ns-resize
@@ -94,16 +93,6 @@ label-empty-padding = 1
type = internal/xwindow
label = %title:0:60:...%
[module/filesystem]
type = internal/fs
interval = 25
mount-0 = /
label-mounted = %{F#F0C674}%mountpoint%%{F-} %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.disabled}
[module/pulseaudio]
type = internal/pulseaudio
@@ -117,29 +106,38 @@ label-volume = %percentage%%
label-muted = muted
label-muted-foreground = ${colors.disabled}
[module/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock
label-layout = %layout%
label-layout-foreground = ${colors.primary}
[module/date-time]
type = internal/date
interval = 43200
label-foreground = ${colors.primary}
label = %date%
label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-foreground = ${colors.background}
label-indicator-background = ${colors.secondary}
[module/date]
inherit = module/date-time
interval = 30
date = %a %d
[module/time]
inherit = module/date-time
interval = 1
date = %H:%M
[module/memory]
type = internal/memory
interval = 2
format-prefix = "RAM "
format = "%{A1:alacritty -e 'glances':}<prefix> <label>%{A}"
format-prefix = " "
format-prefix-foreground = ${colors.primary}
label = %percentage_used:2%%
[module/cpu]
type = internal/cpu
interval = 2
format-prefix = "CPU "
format = "%{A1:alacritty -e 'glances':}<prefix> <label>%{A}"
format-prefix = " "
format-prefix-foreground = ${colors.primary}
label = %percentage:2%%
@@ -153,26 +151,85 @@ label-disconnected = %{F#F0C674}%ifname%%{F#707880} disconnected
[module/wlan]
inherit = network-base
interface-type = wireless
label-connected = %{F#F0C674}%ifname%%{F-} %essid% %local_ip%
; format-connected-prefix = "WIFI "
format-connected-prefix-foreground = ${colors.primary}
format-connected = "%{A1:alacritty -e 'nmtui':}<prefix> <ramp-signal>%{A}"
format-disconnected-prefix-foreground = ${colors.primary}
format-disconnected = "%{A1:alacritty -e 'nmtui':}󰤮%{A}"
ramp-signal-0 = 󰤮
ramp-signal-1 = 󰤟
ramp-signal-2 = 󰤢
ramp-signal-3 = 󰤥
ramp-signal-4 = 󰤨
ramp-signal-5 = 󰤨
[module/eth]
inherit = network-base
interface-type = wired
label-connected = %{F#F0C674}%ifname%%{F-} %local_ip%
label-connected = 󰌘
[module/date]
type = internal/date
interval = 1
[module/battery]
type = internal/battery
full-at = 99
low-at = 5
format-charging-prefix = "󰚥 "
format-charging-prefix-foreground = ${colors.primary}
format-discharging = "<ramp-capacity> <label-discharging>"
format-charging = "<ramp-capacity> <label-charging>"
format-full-prefix = "󰁹 "
format-full-prefix-foreground = ${colors.primary}
format-full = 100%
; Use the following command to list batteries and adapters:
; $ ls -1 /sys/class/power_supply/
battery = BAT0
adapter = ADP1
poll-interval = 5
ramp-capacity-0 = 󰁺
ramp-capacity-1 = 󰁼
ramp-capacity-2 = 󰁾
ramp-capacity-3 = 󰂀
ramp-capacity-4 = 󰂂
; Only applies if <bar-capacity> is used
bar-capacity-width = 10
date = %H:%M
date-alt = %Y-%m-%d %H:%M:%S
label = %date%
label-foreground = ${colors.primary}
[module/bluetooth]
type = custom/script
exec = sh ~/.config/polybar/bluetooth.sh
interval = 2
click-left = exec blueman-manager
click-right = exec ~/.config/polybar/toggle_bluetooth.sh
format-padding = 1
format-foreground = #ffffff
[module/pulseaudio-devices]
type = custom/script
label = "%output%"
label-font = 2
interval = 1.0
exec = sh ~/.config/polybar/sound.sh
click-right = exec pavucontrol &
click-left = sh ~/.config/polybar/sound.sh mute &
; scroll-up = sh ~/.config/polybar/sound.sh up &
; scroll-down = sh ~/.config/polybar/sound.sh down &
[module/weather]
type = custom/script
exec = curl -s https://wttr.in/v%C3%A4nn%C3%A4s?0QTn|grep -oP '(\+|\-)\d{1,2}(?=\()'
interval = 1800
label-foreground= ${colors.primary}
label = %output%°C
[module/power-button]
type = custom/text
format-foreground = ${colors.primary}
label = " 󰐥 "
click-left = sh ~/.config/rofi/powermenu/powermenu.sh
[settings]
screenchange-reload = true
pseudo-transparency = true
; vim:ft=dosini

View File

@@ -0,0 +1,11 @@
#!/bin/sh
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
then
echo "󰂲"
else
if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ]
then
echo "󰥰"
fi
echo ""
fi

View File

@@ -0,0 +1,7 @@
#!/bin/sh
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
then
bluetoothctl power on
else
bluetoothctl power off
fi

229
polybar/polybar/config.ini Normal file
View File

@@ -0,0 +1,229 @@
;==========================================================
;
;
; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗
; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗
; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝
; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗
; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║
; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
;
;
; To learn more about how to configure Polybar
; go to https://github.com/polybar/polybar
;
; The README contains a lot of information
;
;==========================================================
[colors]
background = #24283b
background-alt = #292e42
foreground = #c0caf5
primary = #bb9af7
secondary = #ff007c
alert = #db4b4b
disabled = #565f89
[bar/example]
monitor=${env:MONITOR:}
width = 100%
height = 24pt
radius = 6
; dpi = 96
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 3pt
border-size = 4pt
border-color = #00000000
padding-left = 2
padding-right = 2
module-margin = 1
separator =
separator-foreground = ${colors.disabled}
font-0 = JetbrainsMonoNerdFont;2
fixed-center = true
modules-left = xworkspaces xwindow
modules-center = date time
modules-right = pulseaudio-devices wlan eth bluetooth memory cpu battery weather
cursor-click = pointer
cursor-scroll = ns-resize
enable-ipc = true
; wm-restack = generic
; wm-restack = bspwm
; wm-restack = i3
; override-redirect = true
[module/systray]
type = internal/tray
format-margin = 8pt
tray-spacing = 16pt
[module/xworkspaces]
type = internal/xworkspaces
label-active = %name%
label-active-background = ${colors.background-alt}
label-active-underline= ${colors.primary}
label-active-padding = 1
label-occupied = %name%
label-occupied-padding = 1
label-urgent = %name%
label-urgent-background = ${colors.alert}
label-urgent-padding = 1
label-empty = %name%
label-empty-foreground = ${colors.disabled}
label-empty-padding = 1
[module/xwindow]
type = internal/xwindow
label = %title:0:60:...%
[module/pulseaudio]
type = internal/pulseaudio
format-volume-prefix = "VOL "
format-volume-prefix-foreground = ${colors.primary}
format-volume = <label-volume>
label-volume = %percentage%%
label-muted = muted
label-muted-foreground = ${colors.disabled}
[module/date-time]
type = internal/date
interval = 43200
label-foreground = ${colors.primary}
label = %date%
[module/date]
inherit = module/date-time
interval = 30
date = %a %d
[module/time]
inherit = module/date-time
interval = 1
date = %H:%M
[module/memory]
type = internal/memory
interval = 2
format = "%{A1:alacritty -e 'glances':}<prefix> <label>%{A}"
format-prefix = " "
format-prefix-foreground = ${colors.primary}
label = %percentage_used:2%%
[module/cpu]
type = internal/cpu
interval = 2
format = "%{A1:alacritty -e 'glances':}<prefix> <label>%{A}"
format-prefix = " "
format-prefix-foreground = ${colors.primary}
label = %percentage:2%%
[network-base]
type = internal/network
interval = 5
format-connected = <label-connected>
format-disconnected = <label-disconnected>
label-disconnected = %{F#F0C674}%ifname%%{F#707880} disconnected
[module/wlan]
inherit = network-base
interface-type = wireless
; format-connected-prefix = "WIFI "
format-connected-prefix-foreground = ${colors.primary}
format-connected = "%{A1:alacritty -e 'nmtui':}<prefix> <ramp-signal>%{A}"
format-disconnected-prefix-foreground = ${colors.primary}
format-disconnected = "%{A1:alacritty -e 'nmtui':}󰤮%{A}"
ramp-signal-0 = 󰤮
ramp-signal-1 = 󰤟
ramp-signal-2 = 󰤢
ramp-signal-3 = 󰤥
ramp-signal-4 = 󰤨
ramp-signal-5 = 󰤨
[module/eth]
inherit = network-base
interface-type = wired
label-connected = 󰌘
[module/battery]
type = internal/battery
full-at = 99
low-at = 5
format-charging-prefix = "󰚥 "
format-charging-prefix-foreground = ${colors.primary}
format-discharging = "<ramp-capacity> <label-discharging>"
format-charging = "<ramp-capacity> <label-charging>"
format-full-prefix = "󰁹 "
format-full-prefix-foreground = ${colors.primary}
format-full = 100%
; Use the following command to list batteries and adapters:
; $ ls -1 /sys/class/power_supply/
battery = BAT0
adapter = ADP1
poll-interval = 5
ramp-capacity-0 = 󰁺
ramp-capacity-1 = 󰁼
ramp-capacity-2 = 󰁾
ramp-capacity-3 = 󰂀
ramp-capacity-4 = 󰂂
; Only applies if <bar-capacity> is used
bar-capacity-width = 10
[module/bluetooth]
type = custom/script
exec = sh ~/.config/polybar/bluetooth.sh
interval = 2
click-left = exec blueman-manager
click-right = exec ~/.config/polybar/toggle_bluetooth.sh
format-padding = 1
format-foreground = #ffffff
[module/pulseaudio-devices]
type = custom/script
label = "%output%"
label-font = 2
interval = 1.0
exec = sh ~/.config/polybar/sound.sh
click-right = exec pavucontrol &
click-left = sh ~/.config/polybar/sound.sh mute &
; scroll-up = sh ~/.config/polybar/sound.sh up &
; scroll-down = sh ~/.config/polybar/sound.sh down &
[module/weather]
type = custom/script
exec = curl -s https://wttr.in/v%C3%A4nn%C3%A4s?0QTn|grep -oP '(\+|\-)\d{1,2}(?=\()'
interval = 1800
label-foreground= ${colors.primary}
label = %output%°C
[settings]
screenchange-reload = true
pseudo-transparency = true

23
polybar/polybar/sound.sh Normal file
View File

@@ -0,0 +1,23 @@
function main() {
# Pipewire
active_device=$(pamixer --get-default-sink | awk -F'"' '/Default sink/{next} {print $(NF-1)}')
VOLUME=$(pamixer --get-volume-human)
action=$1
if [ "${action}" == "up" ]; then
pamixer -i 5
elif [ "${action}" == "down" ]; then
pamixer -d 5
elif [ "${action}" == "mute" ]; then
pamixer -t
else
if [ "$VOLUME" == "muted" ]; then
echo "$active_device 󰝟"
else
echo "$active_device$VOLUME"
fi
fi
}
main $@

View File

@@ -0,0 +1,7 @@
killall -q polybar
# Launch bar on each monitor, tray on primary
polybar --list-monitors | while IFS=$'\n' read line; do
monitor=$(echo $line | cut -d':' -f1)
primary=$(echo $line | cut -d' ' -f3)
MONITOR=$monitor polybar --reload "example" &
done

23
polybar/sound.sh Normal file
View File

@@ -0,0 +1,23 @@
function main() {
# Pipewire
active_device=$(pamixer --get-default-sink | awk -F'"' '/Default sink/{next} {print $(NF-1)}')
VOLUME=$(pamixer --get-volume-human)
action=$1
if [ "${action}" == "up" ]; then
pamixer -i 5
elif [ "${action}" == "down" ]; then
pamixer -d 5
elif [ "${action}" == "mute" ]; then
pamixer -t
else
if [ "$VOLUME" == "muted" ]; then
echo "$active_device 󰝟"
else
echo "$active_device$VOLUME"
fi
fi
}
main $@