Skip to content

Instantly share code, notes, and snippets.

@fmoralesc
Last active July 29, 2022 11:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmoralesc/bd46e97b39ee284af641 to your computer and use it in GitHub Desktop.
Save fmoralesc/bd46e97b39ee284af641 to your computer and use it in GitHub Desktop.
Custom launcher for neovim in the gnome-terminal.

Custom launcher for neovim in the gnome-terminal.

Instructions

  • Copy nvim-wrapper somewhere in your $PATH
  • Copy neovim.desktop to ~/.local/share/applications (for the current user) or /usr/share/applications (for a global install)
  • Modify the neovim.desktop file to point Icon= and Exec= to the proper paths where the neovim icon and the neovim-wrapper script are
  • Profit!
[Desktop Entry]
Version=1.0
Type=Application
Name=Neovim
Icon=/home/felipe/images/misc/neovim-mark.png
Exec=/home/felipe/bin/nvim-wrapper %F
NoDisplay=false
Categories=X-GNOME-Other;
StartupNotify=false
Terminal=false
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
#!/usr/bin/env python3
from sys import argv
from subprocess import Popen
from time import time
import dbus
session_bus = dbus.SessionBus()
# launch the terminal server with a custom app-id and window class (so the .desktop file gets associated)
Popen("/usr/lib/gnome-terminal/gnome-terminal-server --app-id org.neovim --class=neovim".split())
# wait until the name is registered
timeout = time() + 1
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:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment