From 8e063f09e70584485ab8f2f7e28cd94fed7fb7fd Mon Sep 17 00:00:00 2001
From: pancakes
Date: Tue, 26 Aug 2025 15:23:49 +1000
Subject: [PATCH] Make it functional
---
DeltatuneWls/DeltatuneWls.csproj | 6 +++++
DeltatuneWls/Program.cs | 28 +++++++++++++++++++----
DeltatuneWls/style.css | 39 ++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 4 deletions(-)
create mode 100644 DeltatuneWls/style.css
diff --git a/DeltatuneWls/DeltatuneWls.csproj b/DeltatuneWls/DeltatuneWls.csproj
index 8c9ef42..e1b4216 100644
--- a/DeltatuneWls/DeltatuneWls.csproj
+++ b/DeltatuneWls/DeltatuneWls.csproj
@@ -15,4 +15,10 @@
+
+
+ PreserveNewest
+
+
+
diff --git a/DeltatuneWls/Program.cs b/DeltatuneWls/Program.cs
index f404a4b..4b5da9a 100644
--- a/DeltatuneWls/Program.cs
+++ b/DeltatuneWls/Program.cs
@@ -1,8 +1,12 @@
-using Gio;
+using Gdk;
+using Gio;
using GLib;
using Gtk;
+using Pango;
using ZwlrLayerShell;
using Application = Gtk.Application;
+using TimeSpan = System.TimeSpan;
+using Variant = GLib.Variant;
if (!LayerShell.IsSupported())
{
@@ -17,7 +21,7 @@ var application = Application.New("gay.pancakes.deltatune_wls", Gio.ApplicationF
GLib.Functions.TimeoutAdd(GLib.Constants.PRIORITY_DEFAULT, 500, () =>
{
if (window == null) return true;
-
+
var playerctl = Subprocess.New(["playerctl", "metadata", "--format", "{{ title }}"],
SubprocessFlags.StdoutPipe | SubprocessFlags.StderrSilence);
@@ -40,11 +44,14 @@ application.OnActivate += (sender, eventArgs) =>
LayerShell.SetNamespace(window, "deltatune-wls");
LayerShell.SetLayer(window, Layer.Top);
LayerShell.SetAnchor(window, Edge.Left, true);
+ LayerShell.SetAnchor(window, Edge.Right, true);
LayerShell.SetAnchor(window, Edge.Top, true);
LayerShell.SetMargin(window, 15);
+ LayerShell.SetMargin(window, Edge.Left, 55);
var label = Label.New(null);
- label.Halign = Align.Start;
+ label.Halign = Align.Start;
+ label.Ellipsize = EllipsizeMode.End;
window.SetChild(label);
@@ -59,7 +66,15 @@ application.OnActivate += (sender, eventArgs) =>
if (newTitle != title)
{
simpleAction.SetState(signalArgs.Parameter);
- label.SetLabel($"♪ - {newTitle}");
+ label.SetLabel($"♪ ~ {newTitle}");
+ if (!label.HasCssClass("fade-in"))
+ {
+ label.AddCssClass("fade-in");
+ GLib.Functions.TimeoutAddSeconds(GLib.Constants.PRIORITY_DEFAULT, 9, () => {
+ label.RemoveCssClass("fade-in");
+ return false;
+ });
+ }
}
};
window.AddAction(action);
@@ -67,4 +82,9 @@ application.OnActivate += (sender, eventArgs) =>
window.Present();
};
+var css = CssProvider.New();
+css.LoadFromPath("style.css");
+StyleContext.AddProviderForDisplay(Display.GetDefault()!, css,
+ Gtk.Constants.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
return application.RunWithSynchronizationContext(null);
\ No newline at end of file
diff --git a/DeltatuneWls/style.css b/DeltatuneWls/style.css
new file mode 100644
index 0000000..1e7e4a0
--- /dev/null
+++ b/DeltatuneWls/style.css
@@ -0,0 +1,39 @@
+window {
+ background-color: transparent;
+}
+
+window label {
+ font-size: x-large;
+ color: white;
+ text-shadow: -1px -1px 0 #15249a, 1px -1px 0 #15249a, -1px 1px 0 #15249a, 1px 1px 0 #15249a;;
+ opacity: 0;
+}
+
+.fade-in {
+ animation: 8s fade-in ease-in-out both;
+}
+
+@keyframes fade-in {
+ 0% {
+ transform: translateX(80px);
+ opacity: 0;
+ }
+
+ 5% {
+ transform: translateX(50px);
+ opacity: 1;
+ }
+
+ 80% {
+ opacity: 1;
+ }
+
+ 85% {
+ transform: translateX(50px);
+ }
+
+ 100% {
+ transform: translateX(0);
+ opacity: 0;
+ }
+}