Compare commits

..

No commits in common. "f424686fe8c0da5aa2cf95de83acb6ff2954c79c" and "a55a67ee66082249fc6d2f39e87b870939dbcbd5" have entirely different histories.

5 changed files with 17 additions and 168 deletions

View file

@ -4,5 +4,5 @@
monitor=DP-1, 3440x1440@100, 1920x0, 1 monitor=DP-1, 3440x1440@100, 1920x0, 1
monitor=HDMI-A-2, 1920x1200@60, 0x0, 1 monitor=HDMI-A-2, 1920x1200@60, 0x0, 1
#monitor=HDMI-A-1, 1920x1200@60, 2680x1440, 1 monitor=HDMI-A-1, 1920x1200@60, 2680x1440, 1
#monitor=HDMI-A-2, 1366x768@60, 0x0, 1 #monitor=HDMI-A-2, 1366x768@60, 0x0, 1

View file

@ -20,7 +20,7 @@ windowrulev2 = suppressevent maximize, class:.*
# Pavucontrol # Pavucontrol
windowrulev2 = float, class:^(org.pulseaudio.pavucontrol)$ windowrulev2 = float, class:^(org.pulseaudio.pavucontrol)$
windowrulev2 = size 696 570, class:^(org.pulseaudio.pavucontrol)$ windowrulev2 = size 696 570, class:^(org.pulseaudio.pavucontrol)$
windowrulev2 = move 1654 807, class:^(org.pulseaudio.pavucontrol)$ windowrulev2 = move 711 376, class:^(org.pulseaudio.pavucontrol)$
windowrulev2 = monitor DP-1, class:^(org.pulseaudio.pavucontrol)$ windowrulev2 = monitor DP-1, class:^(org.pulseaudio.pavucontrol)$
windowrulev2 = opacity 0.9, class:^(org.pulseaudio.pavucontrol)$ windowrulev2 = opacity 0.9, class:^(org.pulseaudio.pavucontrol)$

View file

@ -1,151 +0,0 @@
#!/usr/bin/env python3
import gi
gi.require_version('Playerctl', '2.0')
from gi.repository import Playerctl, GLib
from typing import List, Self
from argparse import ArgumentParser
import json
import sys
parser = ArgumentParser()
parser.add_argument("-l", "--main-loop", action="store_true")
parser.add_argument("-p", "--play-pause", action="store_true")
parser.add_argument("-N", "--next", action="store_true")
parser.add_argument("-P", "--previous", action="store_true")
args = parser.parse_args()
PLAY_ICON = " "
PAUSE_ICON = " "
manager = Playerctl.PlayerManager()
class json_data(dict):
def __init__(self) -> None:
super().__init__()
self["text"] = ""
self["alt"] = ""
self["tooltip"] = ""
self["icon"] = ""
def print(self, data=(), **kwargs) -> Self:
super().update(data, **kwargs)
out = {
"text": str(self.get("icon")) + str(self.get("text")),
"alt": self["alt"],
"tooltip": self["tooltip"]
}
sys.stdout.write(json.dumps(out) + '\n')
sys.stdout.flush()
return self
jdata: json_data = json_data()
def on_play(player, status, manager):
global jdata
jdata.print({"icon": PLAY_ICON})
def on_pause(player, status, manager):
global jdata
jdata.print({"icon": PAUSE_ICON})
def on_metadata(player, metadata, manager):
global jdata
keys = metadata.keys()
if 'xesam:artist' in keys and 'xesam:title' in keys:
jdata.print(
{
"text": f'{metadata['xesam:artist'][0]} - {metadata['xesam:title']}',
"alt": metadata['xesam:title'],
"tooltip": f'{', '.join(metadata['xesam:artist'])} - {metadata['xesam:title']}'
}
)
def init_player(name):
if name.name in ['spotify']:
player = Playerctl.Player.new_from_name(name)
player.connect('playback-status::playing', on_play, manager)
player.connect('playback-status::paused', on_pause, manager)
player.connect('metadata', on_metadata, manager)
manager.manage_player(player)
def on_name_appeared(manager, name):
init_player(name)
def on_player_vanished(manager, player):
jdata.print({"text": "", "icon": ""})
def get_spotify() -> Playerctl.Player | None:
for name in manager.props.player_names:
if name.name in ['spotify']:
return Playerctl.Player.new_from_name(name)
def main_loop():
manager.connect('name-appeared', on_name_appeared)
manager.connect('player-vanished', on_player_vanished)
for name in manager.props.player_names:
init_player(name)
if spotify := get_spotify():
jdata.print(
{
"text": f'{spotify.get_artist()} - {spotify.get_title()}',
"alt": spotify.get_title(),
"tooltip": f'{spotify.get_artist()} - {spotify.get_title()}'
}
)
if spotify.props.status == "Playing":
jdata.print({"icon": PLAY_ICON})
else:
jdata.print({"icon": PAUSE_ICON})
else:
jdata.print({"text": "", "percentage": 0})
main = GLib.MainLoop()
main.run()
def play_pause():
if spotify := get_spotify():
spotify.play_pause()
def next():
if spotify := get_spotify():
spotify.next()
def previous():
if spotify := get_spotify():
spotify.previous()
if args.main_loop:
try:
main_loop()
except KeyboardInterrupt:
exit(0)
exit(1)
if args.play_pause:
play_pause()
exit(0)
if args.next:
next()
exit(0)
if args.previous:
previous()
exit(0)

View file

@ -12,7 +12,7 @@ window#waybar {
/* background: @base; */ /* background: @base; */
transition-property: background-color; transition-property: background-color;
transition-duration: .5s; transition-duration: .5s;
border-radius: 0px 0px 14px 14px; border-radius: 14px 14px 0px 0px;
} }
#workspaces { #workspaces {
@ -47,7 +47,7 @@ window#waybar {
#custom-power, #custom-runner, #battery, #custom-power, #custom-runner, #battery,
#backlight, #wireplumber, #wireplumber.muted, #backlight, #wireplumber, #wireplumber.muted,
#tray, #language, #clock, #custom-spotify { #tray, #language, #clock {
background: @mantle; background: @mantle;
border-radius: 14px; border-radius: 14px;
color: @text; color: @text;
@ -59,7 +59,7 @@ window#waybar {
padding: 0px 9px; padding: 0px 9px;
} }
#custom-spotify { #custom-runner {
padding: 0px 10px; padding: 0px 10px;
} }

View file

@ -1,22 +1,22 @@
{ {
"position": "top", "position": "bottom",
"height": 34, "height": 36,
"width": 900, "width": 900,
"spacing": 0, "spacing": 0,
"margin-bottom": 0,
"layer": "top", "layer": "top",
"margin-bottom": -15, "modules-left": ["tray"],
"modules-left": ["tray", "custom/spotify"],
"modules-center": ["hyprland/workspaces"], "modules-center": ["hyprland/workspaces"],
"modules-right": ["wireplumber", "hyprland/language", "clock"], "modules-right": ["wireplumber", "hyprland/language", "clock"],
"custom/spotify": { "custom/power": {
"format": "{}", "format": "",
"hide-empty-text": true, "on-click": "~/.config/hypr/bin/powermenu"
"return-type": "json", },
"exec": "~/.config/waybar/bin/spotify-info -l",
"on-click": "~/.config/waybar/bin/spotify-info -p", "custom/runner": {
"on-scroll-up": "~/.config/waybar/bin/spotify-info -N", "format": "",
"on-scroll-down": "~/.config/waybar/bin/spotify-info -P" "on-click": "hyprlauncher"
}, },
"hyprland/workspaces": { "hyprland/workspaces": {