diff options
author | Vincent Ambo <mail@tazj.in> | 2023-08-26T23·07+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-08-26T23·30+0000 |
commit | b5979f26e8f47638520b0954ac2f1b794ca58880 (patch) | |
tree | 812c8b157112d718db32085668fae60ba63db88e /users/tazjin/gio-list-apps/src | |
parent | 184020a6f2dde1458791124689829c6f1355ad18 (diff) |
feat(tazjin/gio-list-apps): CLI to list xdg apps using Gio library r/6528
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 <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to '')
-rw-r--r-- | users/tazjin/gio-list-apps/src/main.rs | 19 |
1 files changed, 19 insertions, 0 deletions
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 000000000000..2b04ac06a754 --- /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, + }) + ); + } + } + } +} |