Add Home Manager service integration
This commit is contained in:
parent
be697a6d1c
commit
6cdfab05c0
3 changed files with 216 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
import colorsys
|
||||
import math
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
from io import BytesIO
|
||||
|
|
@ -26,10 +27,11 @@ PALETTE_SIZE = 32
|
|||
OKLCH_LIGHTNESS = 0.72
|
||||
OKLCH_CHROMA = 0.24
|
||||
MAX_BRIGHTNESS_STEP = 0.10
|
||||
PLAYERCTL_BIN = os.environ.get("PLAYERCTL_BIN", "playerctl")
|
||||
|
||||
|
||||
def run_playerctl(field: str, player: str | None = None) -> str:
|
||||
command = ["playerctl"]
|
||||
command = [PLAYERCTL_BIN]
|
||||
if player:
|
||||
command.extend(["--player", player])
|
||||
command.extend(["metadata", field])
|
||||
|
|
@ -46,7 +48,7 @@ def run_playerctl(field: str, player: str | None = None) -> str:
|
|||
|
||||
def list_players() -> list[str]:
|
||||
result = subprocess.run(
|
||||
["playerctl", "-l"],
|
||||
[PLAYERCTL_BIN, "-l"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
|
@ -57,7 +59,7 @@ def list_players() -> list[str]:
|
|||
|
||||
def player_status(player: str) -> str:
|
||||
result = subprocess.run(
|
||||
["playerctl", "--player", player, "status"],
|
||||
[PLAYERCTL_BIN, "--player", player, "status"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
|
@ -79,7 +81,7 @@ def get_track_url(player: str) -> str:
|
|||
|
||||
def get_player_name(player: str) -> str:
|
||||
result = subprocess.run(
|
||||
["playerctl", "--player", player, "metadata", "--format", "{{playerName}}"],
|
||||
[PLAYERCTL_BIN, "--player", player, "metadata", "--format", "{{playerName}}"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue