From b5979f26e8f47638520b0954ac2f1b794ca58880 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 27 Aug 2023 02:07:07 +0300 Subject: feat(tazjin/gio-list-apps): CLI to list xdg apps using Gio library This does nothing other than dump out the list of XDG apps to stdout in JSON format. There are no options or anything. This can be used for selection in app launchers (e.g. dmenu, something based on completing-read in emacs, rofi, etc.). I wrote this because I don't want to deal with having to do this in Elisp. It's also unclear what logic actually hides behind under the hood here, so why not just use the official library. Change-Id: I16fed2c92760cadecc02c59a4e537a1fa247aff9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9157 Reviewed-by: tazjin Tested-by: BuildkiteCI --- users/tazjin/gio-list-apps/src/main.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 users/tazjin/gio-list-apps/src/main.rs (limited to 'users/tazjin/gio-list-apps/src/main.rs') diff --git a/users/tazjin/gio-list-apps/src/main.rs b/users/tazjin/gio-list-apps/src/main.rs new file mode 100644 index 0000000000..2b04ac06a7 --- /dev/null +++ b/users/tazjin/gio-list-apps/src/main.rs @@ -0,0 +1,19 @@ +use gio::traits::AppInfoExt; +use gio::AppInfo; +use serde_json::json; + +fn main() { + for app in AppInfo::all() { + if app.should_show() { + if let Some(cmd) = app.commandline() { + println!( + "{}", + json!({ + "name": app.name().as_str(), + "commandline": cmd, + }) + ); + } + } + } +} -- cgit 1.4.1