Make it functional
This commit is contained in:
parent
0fbf4aa619
commit
8e063f09e7
3 changed files with 69 additions and 4 deletions
|
@ -15,4 +15,10 @@
|
||||||
<ProjectReference Include="..\ZwlrLayerShell\ZwlrLayerShell\ZwlrLayerShell.csproj" />
|
<ProjectReference Include="..\ZwlrLayerShell\ZwlrLayerShell\ZwlrLayerShell.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="style.css">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
using Gio;
|
using Gdk;
|
||||||
|
using Gio;
|
||||||
using GLib;
|
using GLib;
|
||||||
using Gtk;
|
using Gtk;
|
||||||
|
using Pango;
|
||||||
using ZwlrLayerShell;
|
using ZwlrLayerShell;
|
||||||
using Application = Gtk.Application;
|
using Application = Gtk.Application;
|
||||||
|
using TimeSpan = System.TimeSpan;
|
||||||
|
using Variant = GLib.Variant;
|
||||||
|
|
||||||
if (!LayerShell.IsSupported())
|
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, () =>
|
GLib.Functions.TimeoutAdd(GLib.Constants.PRIORITY_DEFAULT, 500, () =>
|
||||||
{
|
{
|
||||||
if (window == null) return true;
|
if (window == null) return true;
|
||||||
|
|
||||||
var playerctl = Subprocess.New(["playerctl", "metadata", "--format", "{{ title }}"],
|
var playerctl = Subprocess.New(["playerctl", "metadata", "--format", "{{ title }}"],
|
||||||
SubprocessFlags.StdoutPipe | SubprocessFlags.StderrSilence);
|
SubprocessFlags.StdoutPipe | SubprocessFlags.StderrSilence);
|
||||||
|
|
||||||
|
@ -40,11 +44,14 @@ application.OnActivate += (sender, eventArgs) =>
|
||||||
LayerShell.SetNamespace(window, "deltatune-wls");
|
LayerShell.SetNamespace(window, "deltatune-wls");
|
||||||
LayerShell.SetLayer(window, Layer.Top);
|
LayerShell.SetLayer(window, Layer.Top);
|
||||||
LayerShell.SetAnchor(window, Edge.Left, true);
|
LayerShell.SetAnchor(window, Edge.Left, true);
|
||||||
|
LayerShell.SetAnchor(window, Edge.Right, true);
|
||||||
LayerShell.SetAnchor(window, Edge.Top, true);
|
LayerShell.SetAnchor(window, Edge.Top, true);
|
||||||
LayerShell.SetMargin(window, 15);
|
LayerShell.SetMargin(window, 15);
|
||||||
|
LayerShell.SetMargin(window, Edge.Left, 55);
|
||||||
|
|
||||||
var label = Label.New(null);
|
var label = Label.New(null);
|
||||||
label.Halign = Align.Start;
|
label.Halign = Align.Start;
|
||||||
|
label.Ellipsize = EllipsizeMode.End;
|
||||||
|
|
||||||
window.SetChild(label);
|
window.SetChild(label);
|
||||||
|
|
||||||
|
@ -59,7 +66,15 @@ application.OnActivate += (sender, eventArgs) =>
|
||||||
if (newTitle != title)
|
if (newTitle != title)
|
||||||
{
|
{
|
||||||
simpleAction.SetState(signalArgs.Parameter);
|
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);
|
window.AddAction(action);
|
||||||
|
@ -67,4 +82,9 @@ application.OnActivate += (sender, eventArgs) =>
|
||||||
window.Present();
|
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);
|
return application.RunWithSynchronizationContext(null);
|
39
DeltatuneWls/style.css
Normal file
39
DeltatuneWls/style.css
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue