summaryrefslogtreecommitdiff
path: root/examples/vala
diff options
context:
space:
mode:
Diffstat (limited to 'examples/vala')
-rw-r--r--examples/vala/simple-bar/README.md1
-rw-r--r--examples/vala/simple-bar/app.in.vala20
-rw-r--r--examples/vala/simple-bar/flake.lock62
-rw-r--r--examples/vala/simple-bar/widget/Bar.vala7
4 files changed, 83 insertions, 7 deletions
diff --git a/examples/vala/simple-bar/README.md b/examples/vala/simple-bar/README.md
index 997e4bf..d33e57d 100644
--- a/examples/vala/simple-bar/README.md
+++ b/examples/vala/simple-bar/README.md
@@ -11,3 +11,4 @@ A simple bar for Hyprland using
- [Network library](https://aylur.github.io/astal/libraries/network).
- [Tray library](https://aylur.github.io/astal/libraries/tray).
- [WirePlumber library](https://aylur.github.io/astal/libraries/wireplumber).
+- [dart-sass](https://sass-lang.com/dart-sass/) as the css precompiler
diff --git a/examples/vala/simple-bar/app.in.vala b/examples/vala/simple-bar/app.in.vala
index 1d61b3a..aece979 100644
--- a/examples/vala/simple-bar/app.in.vala
+++ b/examples/vala/simple-bar/app.in.vala
@@ -1,6 +1,11 @@
class App : Astal.Application {
public static App instance;
+ public override void request (string msg, SocketConnection conn) {
+ print(@"$msg\n");
+ Astal.write_sock.begin(conn, "hello");
+ }
+
public override void activate () {
foreach (var mon in this.monitors)
add_window(new Bar(mon));
@@ -8,8 +13,17 @@ class App : Astal.Application {
apply_css("@STYLE@");
}
- public static int main() {
- App.instance = new App();
- return App.instance.run(null);
+ public static void main(string[] args) {
+ var instance_name = "simple-bar";
+
+ App.instance = new App() {
+ instance_name = instance_name
+ };
+
+ if (App.instance.acquire_socket()) {
+ App.instance.run(null);
+ } else {
+ print(Astal.Application.send_message(instance_name, string.joinv(" ", args)));
+ }
}
}
diff --git a/examples/vala/simple-bar/flake.lock b/examples/vala/simple-bar/flake.lock
new file mode 100644
index 0000000..06f572f
--- /dev/null
+++ b/examples/vala/simple-bar/flake.lock
@@ -0,0 +1,62 @@
+{
+ "nodes": {
+ "astal": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1727022015,
+ "narHash": "sha256-ka7aRbReUE6ImjQV8KabMHoojUgb3gtn1/9drMFTtBk=",
+ "owner": "aylur",
+ "repo": "astal",
+ "rev": "8cab7d039e2cf783033a5f1f26cf8be42b0d158e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "aylur",
+ "repo": "astal",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1716293225,
+ "narHash": "sha256-pU9ViBVE3XYb70xZx+jK6SEVphvt7xMTbm6yDIF4xPs=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "3eaeaeb6b1e08a016380c279f8846e0bd8808916",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1726937504,
+ "narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "9357f4f23713673f310988025d9dc261c20e70c6",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "astal": "astal",
+ "nixpkgs": "nixpkgs_2"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/examples/vala/simple-bar/widget/Bar.vala b/examples/vala/simple-bar/widget/Bar.vala
index 438e8b7..6e99327 100644
--- a/examples/vala/simple-bar/widget/Bar.vala
+++ b/examples/vala/simple-bar/widget/Bar.vala
@@ -137,10 +137,9 @@ class SysTray : Gtk.Box {
}
void remove_item(string id) {
- if (!items.contains(id))
- return;
-
- items.remove(id);
+ if (items.contains(id)) {
+ items.remove(id);
+ }
}
}