mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-31 08:14:26 +02:00
xdg-app-chooser: use system Python
This commit is contained in:
parent
b0fd8f4a04
commit
d216960acd
1 changed files with 6 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
"""Simple application selector relying on GTK app chooser dialog.
|
"""Simple application selector relying on GTK app chooser dialog.
|
||||||
"""
|
"""
|
||||||
|
@ -13,9 +13,7 @@ import gi
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
|
parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
|
||||||
parser.add_argument("file",
|
parser.add_argument("file", metavar="FILE", help="file to open")
|
||||||
metavar="FILE",
|
|
||||||
help="file to open")
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
|
@ -27,9 +25,9 @@ file_info = f.query_info("standard::content-type", 0)
|
||||||
content_type = file_info.get_content_type()
|
content_type = file_info.get_content_type()
|
||||||
|
|
||||||
# Display app chooser dialog box
|
# Display app chooser dialog box
|
||||||
dialog = Gtk.AppChooserDialog.new_for_content_type(None,
|
dialog = Gtk.AppChooserDialog.new_for_content_type(
|
||||||
Gtk.DialogFlags.MODAL,
|
None, Gtk.DialogFlags.MODAL, content_type
|
||||||
content_type)
|
)
|
||||||
dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
|
dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
|
||||||
dialog.get_widget().set_show_default(True)
|
dialog.get_widget().set_show_default(True)
|
||||||
dialog.get_widget().set_show_fallback(True)
|
dialog.get_widget().set_show_fallback(True)
|
||||||
|
@ -40,7 +38,5 @@ if response == Gtk.ResponseType.OK:
|
||||||
app_info = dialog.get_app_info()
|
app_info = dialog.get_app_info()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
# TODO: make it launch synchronously
|
# TODO: make it launch synchronously
|
||||||
sys.exit(0
|
sys.exit(0 if app_info.launch([f]) else 1)
|
||||||
if app_info.launch([f])
|
|
||||||
else 1)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue