From c3397a25d497aafd1cfd613a27dd37608aefb717 Mon Sep 17 00:00:00 2001 From: vikingowl Date: Wed, 5 Mar 2025 03:01:44 +0100 Subject: [PATCH] split config into multiple files --- .config/eww/widgets.scss | 42 ++--------------------------- .config/eww/widgets.yuck | 41 ++-------------------------- .config/eww/widgets/lorem-text.scss | 4 +++ .config/eww/widgets/lorem-text.yuck | 5 ++++ .config/eww/widgets/media.scss | 34 +++++++++++++++++++++++ .config/eww/widgets/media.yuck | 33 +++++++++++++++++++++++ 6 files changed, 80 insertions(+), 79 deletions(-) create mode 100644 .config/eww/widgets/lorem-text.scss create mode 100644 .config/eww/widgets/lorem-text.yuck create mode 100644 .config/eww/widgets/media.scss create mode 100644 .config/eww/widgets/media.yuck diff --git a/.config/eww/widgets.scss b/.config/eww/widgets.scss index 78a61b5..9dfc6ff 100644 --- a/.config/eww/widgets.scss +++ b/.config/eww/widgets.scss @@ -1,40 +1,2 @@ - /* Widgets */ -.lorem-text { - background: darkgrey; - color: black; -} - -.music { - background: transparent; - color: transparent; - - &--off { - background: transparent; - color: transparent; - } - - &--on { - background: #8ce513; - color: #010101; - } - - &--spotify { - background: #17d860; - color: #282828; - } - - &--firefox { - background: #fd8728; - color: #010101; - } - - &--mpv { - background: #420042; - color: white; - } - - &--chromium { - background: #1a73e8; - color: white; - } -} +@import 'widgets/media'; +@import 'widgets/lorem-text'; diff --git a/.config/eww/widgets.yuck b/.config/eww/widgets.yuck index bf64ed0..cdd1d0a 100644 --- a/.config/eww/widgets.yuck +++ b/.config/eww/widgets.yuck @@ -1,39 +1,2 @@ -(defwidget loremText [text] - (label :text text - :class 'lorem-text' - ) -) - -; icons used can be found on https://www.nerdfonts.com/cheat-sheet -(defvar playerIcons `{ - "spotify": "", - "mpv": "", - "firefox": "", - "chromium": "" -}`) -(defvar playerRegex "spotify|firefox|mpv|chromium") ; don't forget to update this with your icons -(defvar separator " | ") ; separator between artist and title -(defvar ellipsisIcon "…") ; your icon to display in case of ellipsis -(defvar ellipsisArtist 20) ; set length for ellipsis on artist -(defvar ellipsisTitle 25) ; set length for ellipsis on title -(defwidget media [] - (box :class "media" - :halign "center" - :valign "center" - :class { playerctl == '' || objectlength(playerctl) == 0 - ? 'music--off' - : matches(playerctl.player, playerRegex) - ? 'music--' + playerctl.player - : 'music--on' } - { playerctl == '' || objectlength(playerctl) == 0 - ? '' - : matches(playerctl.player, playerRegex) - ? "${playerIcons[playerctl.player]} ${substring(playerctl.artist, 0, ellipsisArtist)}${strlength(playerctl.artist) >= ellipsisArtist ? ellipsisIcon : ''} | ${substring(playerctl.title, 0, ellipsisTitle)}${strlength(playerctl.title) >= ellipsisTitle ? ellipsisIcon : ''}" - : "${playerctl.player} - ${substring(playerctl.artist, 0, ellipsisArtist)}${strlength(playerctl.artist) >= ellipsisArtist ? ellipsisIcon : ''} | ${ substring(playerctl.title, 0, ellipsisTitle)}${strlength(playerctl.title) >= ellipsisTitle ? ellipsisIcon : ''}" - } - ) -) - -(deflisten playerctl :initial "" - `playerctl --follow metadata --format '{"player": "{{ playerName }}", "trackid": "{{ mpris:trackid }}", "length": "{{ duration(mpris:length) }}", "artUrl": "{{ mrpis:artUrl }}", "album": "{{ album }}", "albumArtist": "{{ xesam:albumArtist }}", "artist": "{{ artist }}", "autoRating": "{{ xesam:autoRating }}", "discNumber": "{{ xesam:discNumber }}", "title": "{{ title }}", "trackNumber": "{{ xesam:trackNumber }}", "url": "{{ xesam:url }}", "position": "{{ position }}"}'` -) +(include "widgets/media.yuck") +(include "widgets/lorem-text.yuck") diff --git a/.config/eww/widgets/lorem-text.scss b/.config/eww/widgets/lorem-text.scss new file mode 100644 index 0000000..b20f2f2 --- /dev/null +++ b/.config/eww/widgets/lorem-text.scss @@ -0,0 +1,4 @@ +.lorem-text { + background: darkgrey; + color: black; +} diff --git a/.config/eww/widgets/lorem-text.yuck b/.config/eww/widgets/lorem-text.yuck new file mode 100644 index 0000000..7fe3755 --- /dev/null +++ b/.config/eww/widgets/lorem-text.yuck @@ -0,0 +1,5 @@ +(defwidget loremText [text] + (label :text text + :class 'lorem-text' + ) +) diff --git a/.config/eww/widgets/media.scss b/.config/eww/widgets/media.scss new file mode 100644 index 0000000..712274c --- /dev/null +++ b/.config/eww/widgets/media.scss @@ -0,0 +1,34 @@ +.music { + background: transparent; + color: transparent; + + &--off { + background: transparent; + color: transparent; + } + + &--on { + background: #8ce513; + color: #010101; + } + + &--spotify { + background: #17d860; + color: #282828; + } + + &--firefox { + background: #fd8728; + color: #010101; + } + + &--mpv { + background: #420042; + color: white; + } + + &--chromium { + background: #1a73e8; + color: white; + } +} diff --git a/.config/eww/widgets/media.yuck b/.config/eww/widgets/media.yuck new file mode 100644 index 0000000..0622570 --- /dev/null +++ b/.config/eww/widgets/media.yuck @@ -0,0 +1,33 @@ +; icons used can be found on https://www.nerdfonts.com/cheat-sheet +(defvar playerIcons `{ + "spotify": "", + "mpv": "", + "firefox": "", + "chromium": "" +}`) +(defvar playerRegex "spotify|firefox|mpv|chromium") ; don't forget to update this with your icons +(defvar separator " | ") ; separator between artist and title +(defvar ellipsisIcon "…") ; your icon to display in case of ellipsis +(defvar ellipsisArtist 20) ; set length for ellipsis on artist +(defvar ellipsisTitle 25) ; set length for ellipsis on title +(defwidget media [] + (box :class "media" + :halign "center" + :valign "center" + :class { playerctl == '' || objectlength(playerctl) == 0 + ? 'music--off' + : matches(playerctl.player, playerRegex) + ? 'music--' + playerctl.player + : 'music--on' } + { playerctl == '' || objectlength(playerctl) == 0 + ? '' + : matches(playerctl.player, playerRegex) + ? "${playerIcons[playerctl.player]} ${substring(playerctl.artist, 0, ellipsisArtist)}${strlength(playerctl.artist) >= ellipsisArtist ? ellipsisIcon : ''} | ${substring(playerctl.title, 0, ellipsisTitle)}${strlength(playerctl.title) >= ellipsisTitle ? ellipsisIcon : ''}" + : "${playerctl.player} - ${substring(playerctl.artist, 0, ellipsisArtist)}${strlength(playerctl.artist) >= ellipsisArtist ? ellipsisIcon : ''} | ${ substring(playerctl.title, 0, ellipsisTitle)}${strlength(playerctl.title) >= ellipsisTitle ? ellipsisIcon : ''}" + } + ) +) + +(deflisten playerctl :initial "" + `playerctl --follow metadata --format '{"player": "{{ playerName }}", "trackid": "{{ mpris:trackid }}", "length": "{{ duration(mpris:length) }}", "artUrl": "{{ mrpis:artUrl }}", "album": "{{ album }}", "albumArtist": "{{ xesam:albumArtist }}", "artist": "{{ artist }}", "autoRating": "{{ xesam:autoRating }}", "discNumber": "{{ xesam:discNumber }}", "title": "{{ title }}", "trackNumber": "{{ xesam:trackNumber }}", "url": "{{ xesam:url }}", "position": "{{ position }}"}'` +)