chore: initial commit

This commit is contained in:
2024-08-08 14:39:30 +02:00
commit 66bdf943c7
12 changed files with 1261 additions and 0 deletions

279
polybar/config.ini Executable file
View File

@@ -0,0 +1,279 @@
;==========================================================
;
;
; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗
; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗
; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝
; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗
; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║
; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
;
;
; To learn more about how to configure Polybar
; go to https://github.com/polybar/polybar
;
; The README contains a lot of information
;
;==========================================================
[colors]
background = #282a36
background-alt = #44475a
foreground = #f8f8f2
primary = #bd93f9
secondary = #ffb86c
alert = #ff5555
disabled = #626682
[bars]
padding-x = 0
padding-y = 0
offset-y = 0
[bar/main]
width = 100%
height = 24pt
radius = 0
border-top-size = ${bars.padding-y}
border-left-size = ${bars.padding-x}
border-right-size = ${bars.padding-x}
bottom = true
line-size = 3pt
offset-y = ${bars.offset-y}
; dpi = 96
background = ${colors.background}
foreground = ${colors.foreground}
border-color = #00000000
padding-left = 1
padding-right = 1
module-margin = 1
separator = " "
separator-foreground = ${colors.disabled}
font-0 = GeistMono Nerd Font:size=12;3
modules-left = xworkspaces
modules-center = spotify
modules-right = mixrs-status filesystem pulseaudio memory cpu date
cursor-click = pointer
cursor-scroll = ns-resize
enable-ipc = true
; wm-restack = generic
wm-restack = bspwm
; wm-restack = i3
override-redirect = false
[bar/bottom]
width = 100%
height = 24pt
radius = 8
border-top-size = 0
border-bottom-size = ${bars.padding-y}
border-left-size = ${bars.padding-x}
border-right-size = ${bars.padding-x}
bottom = true
wm-restack = bspwm
override-redirect = false
; dpi = 96
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 8pt
border-size = 4pt
border-color = #00000000
padding-left = 0
padding-right = 1
module-margin = 1
separator = |
separator-foreground = ${colors.disabled}
font-0 = "GeistMono Nerd Font:size=13:spacing=0:weight=normal;2"
cursor-click = pointer
cursor-scroll = ns-resize
enable-ipc = 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/filesystem]
type = internal/fs
interval = 25
mount-0 = /
label-mounted = %mountpoint%%{F-} %percentage_used%%
label-mounted-foreground = ${colors.primary}
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.disabled}
[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/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock
label-layout = %layout%
label-layout-foreground = ${colors.primary}
label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-foreground = ${colors.background}
label-indicator-background = ${colors.secondary}
[module/memory]
type = internal/memory
interval = 2
format-prefix = "RAM "
format-prefix-foreground = ${colors.primary}
label = %percentage_used:2%%
[module/cpu]
type = internal/cpu
interval = 2
format-prefix = "CPU "
format-prefix-foreground = ${colors.primary}
label = %percentage:2%%
[network-base]
type = internal/network
interval = 3
format-connected = <label-connected>
format-disconnected = <label-disconnected>
label-disconnected = %ifname%%{F-} disconnected
label-disconnected-foreground = ${colors.primary}
[module/wlan]
inherit = network-base
interface-type = wireless
label-connected = %ifname%%{F-} %essid% %local_ip%
label-connected-foreground = ${colors.primary}
[module/eth]
inherit = network-base
interface-type = wired
label-connected = %ifname%%{F-} %local_ip%
label-connected-foreground = ${colors.primary}
[module/date]
type = internal/date
interval = 1
date = "%d.%m.%Y %H:%M:%S"
date-alt = "%H:%M"
label = %date%
label-foreground = ${colors.primary}
[settings]
screenchange-reload = true
pseudo-transparency = true
; vim:ft=dosini
[module/spotify]
type = custom/script
tail = true
interval = 1
; prefix symbol is shown before the text
format = %{T-}<label>
exec = ~/.config/polybar/scripts/scroll_spotify_status.sh
click-left=playerctl play-pause -p spotify
[module/spotify-prev]
type = custom/script
exec = echo "<previous-song-symbol>"
format = <label>
click-left = playerctl previous -p spotify
[module/spotify-play-pause]
type = custom/ipc
hook-0 = echo "<playing-symbol>"
hook-1 = echo "<pause-symbol>"
initial = 1
click-left = playerctl play-pause -p spotify
[module/spotify-next]
type = custom/script
exec = echo "next-song-symbol"
format = <label>
click-left = playerctl next -p spotify
[module/mixrs-status]
type = custom/script
exec = ~/.config/polybar/scripts/get_mixrs_status.sh
tail = true
click-left=echo -ne "\x2" | nc -N -U /tmp/mixrs
scroll-up=echo -ne "\x1" | nc -N -U /tmp/mixrs
scroll-down=echo -ne "\x0" | nc -N -U /tmp/mixrs
cursor-scroll=pointer
label = "%output%"
format-prefix = " "
format-prefix-foreground = ${colors.primary}
format-suffix = " [Mixrs]"
format-suffix-foreground = ${colors.primary}
format = <label>

View File

@@ -0,0 +1,24 @@
#!/bin/sh
while true
do
if ! (echo -ne '\x9' | nc -N -U /tmp/mixrs) >/dev/null 2>&1; then
echo "Offline"
exit 1
fi
raw=$(echo -ne "\x9" | nc -N -U /tmp/mixrs)
if [ ${#raw} -gt 0 ]; then
if [ $(echo "$raw" | grep "muted: " | sed 's/muted: //') = "true" ]; then
output=$(echo "$raw" | grep -e 'selection' -e 'name' | sed -E -e 's/selection: |name: |volume_percentage: //g' | tr '\n' ' ')
echo "${output}Muted"
else
output=$(echo "$raw" | grep -e 'selection' -e 'name' -e 'volume_percentage' | sed -E -e 's/selection: |name: |volume_percentage: //g' | tr '\n' ' ' | sed 's/.$/%\n/')
echo $output
fi
else
echo "0/0"
fi
sleep 0.07s
done

View File

@@ -0,0 +1,50 @@
#!/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="{{ artist }} - {{ title }}"
# 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

View File

@@ -0,0 +1,12 @@
#!/bin/bash
# see man zscroll for documentation of the following parameters
zscroll -l 120 \
--delay 0.3 \
--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