Obtenga el directorio de trabajo actual de VTE (Widget de terminal GTK) en Python
Pregunta
Oye, ¿Cómo puedo obtener el directorio de trabajo actual de un widget de VTE en Python? Gracias.
Solución
PRERTÓRIMIENTO DE LA MARCA, un enfoque ligeramente más elegante:
import vte
import os
v = vte.Terminal()
vPid = v.fork_command()
workingDir = os.readlink('/proc/%s/cwd' % vPid)
Otros consejos
Este es un kludge, pero la mejor manera en que puedo pensar sería:
import vte
import os
v = vte.Terminal()
vPid = v.fork_command()
# make a system call to pwdx to get working director
sIn, sOut = os.popen2("pwdx " + vPid)
workingDir = sOut.read()
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow