From e5b9b32e4d6c1db9b5fd72652bbc3a1d3c1203b5 Mon Sep 17 00:00:00 2001 From: iiogama Date: Wed, 10 Jan 2024 18:38:06 -0800 Subject: [PATCH] Created a now_playing script for waybar to show currently playing song in cmus --- home-manager/dots/way-displays/cfg.yaml | 80 +++++++++++++++++++++++++ home-manager/dots/waybar/config | 10 +++- home-manager/dots/waybar/now_playing.sh | 4 ++ home-manager/wayland.nix | 5 ++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 home-manager/dots/way-displays/cfg.yaml create mode 100755 home-manager/dots/waybar/now_playing.sh diff --git a/home-manager/dots/way-displays/cfg.yaml b/home-manager/dots/way-displays/cfg.yaml new file mode 100644 index 0000000..b3f9707 --- /dev/null +++ b/home-manager/dots/way-displays/cfg.yaml @@ -0,0 +1,80 @@ +# Default cfg.yaml for way-displays. +# Copy this to ~/.config/way-displays/cfg.yaml and edit it to your liking. +# +# See https://github.com/alex-courtis/way-displays/blob/master/doc/CONFIGURATION.md + + +# Arrange displays in a ROW (default, left to right) or a COLUMN (top to bottom) +ARRANGE: ROW + +# Align ROWs at the TOP (default), MIDDLE or BOTTOM +# Align COLUMNs at the LEFT (default), MIDDLE or RIGHT +ALIGN: TOP + + +# The default ORDER is simply the order in which the displays are discovered. +# Define your own. +ORDER: + - 'DP-1' + - 'DP-2' + + +# Enable scaling, overrides AUTO_SCALE and SCALE +SCALING: TRUE + +# The default is to scale each display by DPI. +# This may be disabled and scale 1 will be used, unless a SCALE has been specified. +AUTO_SCALE: TRUE + + +# Auto scale may be overridden for each display. +SCALE: + #- NAME_DESC: 'monitor description' + # SCALE: 1.75 + +# Override the preferred mode. +# WARNING: this may result in an unusable display. See https://github.com/alex-courtis/way-displays#known-issues-with-workarounds +# for a possible workaround. +MODE: + # Resolution and refresh + #- NAME_DESC: HDMI-A-1 + # WIDTH: 1920 + # HEIGHT: 1080 + # HZ: 60 + + # Resolution with highest refresh + #- NAME_DESC: 'monitor description' + # WIDTH: 2560 + # HEIGHT: 1440 + + # Highest available + - NAME_DESC: DP-1 + MAX: TRUE + - NAME_DESC: DP-2 + MAX: TRUE + +# Rotate or translate the display. +# 90, 180, 270, FLIPPED, FLIPPED-90, FLIPPED-180, FLIPPED-270 +TRANSFORM: + # - NAME_DESC: 'monitor description' + # TRANSFORM: 270 + +# VRR / adaptive sync is enabled by default. Disable it per display. +VRR_OFF: + # - DP-2 + # - '!.*my monitor.*' + + +# Laptop displays usually start with eDP e.g. eDP-1. This may be overridden if +# your laptop is different. +#LAPTOP_DISPLAY_PREFIX: 'eDP' + + +# One of: ERROR, WARNING, INFO (default), DEBUG +LOG_THRESHOLD: INFO + + +# Disable the specified displays. +DISABLED: + #- "eDP-1" + diff --git a/home-manager/dots/waybar/config b/home-manager/dots/waybar/config index 6fe70f1..bfa0930 100644 --- a/home-manager/dots/waybar/config +++ b/home-manager/dots/waybar/config @@ -8,7 +8,8 @@ "river/mode" ], "modules-center": [ - "river/window" + "river/window", + "custom/now_playing" ], "modules-right": [ "wlr/taskbar", @@ -20,6 +21,13 @@ "num-tags": 9, "tag-labels": ["1","2","3","4","5","6","7","8","9"] }, + "custom/now_playing": { + "exec": "~/.config/waybar/now_playing.sh", + "return-type": "text", + "format": "{}", + "tooltip": false, + "interval": 900 + }, "wlr/taskbar": { "on-click": "activate", "on-click-middle": "close", diff --git a/home-manager/dots/waybar/now_playing.sh b/home-manager/dots/waybar/now_playing.sh new file mode 100755 index 0000000..91f3109 --- /dev/null +++ b/home-manager/dots/waybar/now_playing.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +NOWPLAYING=$(basename "$(cmus-remote -Q | grep file | cut -f 2- -d ' ')") +echo "{\"text\":\"\"$NOWPLAYING\"}" diff --git a/home-manager/wayland.nix b/home-manager/wayland.nix index 67c5a2d..cbe434a 100644 --- a/home-manager/wayland.nix +++ b/home-manager/wayland.nix @@ -30,5 +30,10 @@ target = "waybar"; recursive = true; }; + "way-displays" = { + source = ./dots/way-displays; + target = "way-displays"; + recursive = true; + }; }; }