aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickaël Delahaye2015-11-02 23:12:42 +0100
committerMickaël Delahaye2015-11-02 23:12:42 +0100
commit1398d2b3614efff94c87c2d61cc01a30fb2ed083 (patch)
treee0be36fc23ad4cd534bdb317d83ef5211b712dc1
parentbdcf70065c1773f5a5ef1c8cd7d747906b365fdb (diff)
downloadaur-1398d2b3614efff94c87c2d61cc01a30fb2ed083.tar.gz
Add more options to launch the terminal and some refactoring
-rwxr-xr-xnvim-wrapper58
1 files changed, 44 insertions, 14 deletions
diff --git a/nvim-wrapper b/nvim-wrapper
index df381352e4e1..6ea768294ae8 100755
--- a/nvim-wrapper
+++ b/nvim-wrapper
@@ -1,19 +1,49 @@
#!/usr/bin/env python3
-from sys import argv
-from subprocess import Popen
-from time import time
+"""Run nvim inside gnome-terminal"""
+
+import sys
+import os
+import subprocess
import dbus
+from time import time
+
+SERVER_CMD = [
+ '/usr/lib/gnome-terminal/gnome-terminal-server',
+ '--app-id=org.neovim',
+]
+TERM_CMD = [
+ 'gnome-terminal',
+ '--name=Neovim',
+ '--hide-menubar',
+ '--geometry=90x60',
+ '--app-id=org.neovim',
+ '--class=neovim',
+ '-x',
+ 'nvim'
+]
+
+def main():
+ """Run nvim inside gnome-terminal"""
+ session_bus = dbus.SessionBus()
+
+ # launch the terminal server with a custom app-id
+ # and window class (so the .desktop file gets associated)
+ if not session_bus.name_has_owner('org.neovim'):
+ subprocess.Popen(SERVER_CMD)
-session_bus = dbus.SessionBus()
+ # wait until the name is registered, or 2 seconds pass (when launching from
+ # cold cache it might more time)
+ timeout = time() + 2
+ while not session_bus.name_has_owner('org.neovim') and time() <= timeout:
+ pass
+ # launch nvim in a gnome-terminal instance
+ if session_bus.name_has_owner('org.neovim'):
+ with open(os.devnull, 'wb') as fnull:
+ subprocess.Popen(TERM_CMD + sys.argv[1:],
+ stdout=fnull,
+ stderr=fnull)
+ # preexec_fn=os.setpgrp)
-# launch the terminal server with a custom app-id and window class (so the .desktop file gets associated)
-if not session_bus.name_has_owner('org.neovim'):
- Popen("/usr/lib/gnome-terminal/gnome-terminal-server --app-id org.neovim --class=neovim".split())
-# wait until the name is registered, or 2 seconds pass (when launching from cold cache it might more time)
-timeout = time() + 2
-while not session_bus.name_has_owner('org.neovim') and time() <= timeout:
- pass
-# launch nvim in a gnome-terminal instance
-if session_bus.name_has_owner('org.neovim'):
- Popen("gnome-terminal --app-id org.neovim -x nvim".split() + argv[1:])
+if __name__ == '__main__':
+ main()