Skip to content

Instantly share code, notes, and snippets.

@jeangjenq
Created March 20, 2022 11:05
Show Gist options
  • Save jeangjenq/cd2f9cee4d0043278c66aa0378ee8d45 to your computer and use it in GitHub Desktop.
Save jeangjenq/cd2f9cee4d0043278c66aa0378ee8d45 to your computer and use it in GitHub Desktop.
Find terminal from any linux distro.
from distutils.spawn import find_executable
def isNot_exec(name):
#check whether terminal program exists
return find_executable(name) is None
def findTerminal():
termList = ["x-terminal-emulator", "konsole", "gnome-terminal", "urxvt", "rxvt", "termit", "terminator", "Eterm", "aterm", "uxterm", "xterm", "roxterm", "xfce4-terminal", "termite", "lxterminal", "mate-terminal", "terminology", "st", "qterminal", "lilyterm", "tilix", "terminix", "kitty", "guake", "tilda", "alacritty", "hyper"]
#list taken from https://github.com/i3/i3/blob/next/i3-sensible-terminal
i = 0
for term in termList:
if isNot_exec(term):
i += 1
else:
break
return termList[i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment