diff --git a/bin/omarchy-branding-about b/bin/omarchy-branding-about
index f8bfd966..a0dad2e2 100755
--- a/bin/omarchy-branding-about
+++ b/bin/omarchy-branding-about
@@ -8,12 +8,10 @@
set -euo pipefail
-SOURCE_DIR="${XDG_PICTURES_DIR:-$HOME/Pictures}"
-
case "${1:-}" in
image)
- image=$(omarchy-menu-file "Pick png/svg from $SOURCE_DIR" "${SOURCE_DIR}" "svg png")
- if [[ -n $image ]] && omarchy-transcode-ascii "$image" ~/.config/omarchy/branding/about.txt --width 54 --height 26; then
+ image=$(omarchy-file-select --title "Pick PNG or SVG for About" --extensions "png svg")
+ if omarchy-transcode-ascii "$image" ~/.config/omarchy/branding/about.txt --width 54 --height 26; then
omarchy-launch-about >/dev/null 2>&1
fi
;;
diff --git a/bin/omarchy-branding-screensaver b/bin/omarchy-branding-screensaver
index 4aaafc58..cf031a61 100755
--- a/bin/omarchy-branding-screensaver
+++ b/bin/omarchy-branding-screensaver
@@ -8,12 +8,10 @@
set -euo pipefail
-SOURCE_DIR="${XDG_PICTURES_DIR:-$HOME/Pictures}"
-
case "${1:-}" in
image)
- image=$(omarchy-menu-file "Pick png/svg from $SOURCE_DIR" "${SOURCE_DIR}" "svg png")
- if [[ -n $image ]] && omarchy-transcode-ascii "$image" ~/.config/omarchy/branding/screensaver.txt; then
+ image=$(omarchy-file-select --title "Pick PNG or SVG for screensaver" --extensions "png svg")
+ if omarchy-transcode-ascii "$image" ~/.config/omarchy/branding/screensaver.txt; then
omarchy-launch-screensaver force >/dev/null 2>&1
fi
;;
diff --git a/bin/omarchy-file-select b/bin/omarchy-file-select
index 6b0fab12..9610a897 100755
--- a/bin/omarchy-file-select
+++ b/bin/omarchy-file-select
@@ -1,8 +1,8 @@
#!/usr/bin/python3
# omarchy:summary=Pick files with the desktop file chooser
-# omarchy:args=[--title
] [--multiple]
-# omarchy:examples=omarchy file select --title "Send with Tailscale" --multiple
+# omarchy:args=[--title ] [--multiple] [--extensions ""]
+# omarchy:examples=omarchy file select --title "Send with Tailscale" --multiple | omarchy file select --title "Pick image" --extensions "png svg"
# Python rather than bash, alone among the commands here, because the portal
# answers a request with a Response signal addressed to the connection that
@@ -36,6 +36,7 @@ def main():
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--title", default="Select file")
parser.add_argument("--multiple", action="store_true")
+ parser.add_argument("--extensions", default="")
args, unknown = parser.parse_known_args()
if unknown:
@@ -71,15 +72,26 @@ def main():
predicted = "/org/freedesktop/portal/desktop/request/%s/%s" % (sender, token)
subscribe(predicted)
+ options = {
+ "handle_token": GLib.Variant("s", token),
+ "multiple": GLib.Variant("b", args.multiple),
+ }
+
+ if args.extensions:
+ # Glob matching in the chooser is case-sensitive, so cover both cases.
+ exts = [ext.lstrip(".").lower() for ext in args.extensions.split()]
+ patterns = [(0, "*." + ext) for ext in exts] + [(0, "*." + ext.upper()) for ext in exts]
+ label = " ".join("*." + ext for ext in exts)
+ filters = GLib.Variant("a(sa(us))", [(label, patterns)])
+ options["filters"] = filters
+ options["current_filter"] = GLib.Variant("(sa(us))", (label, patterns))
+
handle = bus.call_sync(
"org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.FileChooser",
"OpenFile",
- GLib.Variant("(ssa{sv})", ("", args.title, {
- "handle_token": GLib.Variant("s", token),
- "multiple": GLib.Variant("b", args.multiple),
- })),
+ GLib.Variant("(ssa{sv})", ("", args.title, options)),
None,
Gio.DBusCallFlags.NONE,
-1,