【问题标题】:How do I tell python to launch a users default terminal?如何告诉 python 启动用户默认终端?
【发布时间】:2013-05-06 17:51:40
【问题描述】:

我之前找到了这个解决方案,但它一直在尝试启动 xterm 而不是默认的(在我的例子中是终结者)。有人可以帮忙吗?

def terminal(self):
    if sys.platform.startswith('linux'):
        os.system('(cd .;$TERM; )'.format(self.dirname))
    elif sys.platform.startswith('win'):
        os.system('start /d {0} cmd'.format(os.path.normpath(self.dirname)))

【问题讨论】:

  • 以 sudo 或其他可疑的方式运行脚本?
  • TERM是终端能力,与实际终端程序关系不大。
  • 不,它不是作为sudo运行的,那么正确的方法是什么?

标签: python linux terminal


【解决方案1】:

TERM是终端能力,与实际终端程序关系不大。

存储默认值没有标准,这完全取决于您使用的发行版..

可能是

  • 在 /etc/alternatives 中,可能是 /etc/alternatives/x-terminal-emulator
  • 使用 gnome,试试gsettings get org.gnome.desktop.default-applications.terminal

注意:这些都没有尝试过...

【讨论】:

    【解决方案2】:

    这取决于外壳。在 Xfce 中是exo-open --launch TerminalEmulator。在 GNOME 中是x-terminal-emulator

    【讨论】:

      猜你喜欢
      • 2021-12-01
      • 2020-06-09
      • 1970-01-01
      • 2013-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-25
      • 1970-01-01
      相关资源
      最近更新 更多