Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added compatibility with xfce4-terminal #110

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pokemonterminal/adapter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
from pokemonterminal.adapter.implementations.NullAdapter import NullAdapter
from pokemonterminal.adapter.implementations.Terminology import Terminology
from pokemonterminal.adapter.implementations.Tilix import Tilix
from pokemonterminal.adapter.implementations.Xfce4Terminal import Xfce4Terminal



available_terminals = [
Terminology,
Tilix,
ITerm
ITerm,
Xfce4Terminal
]


Expand Down
39 changes: 39 additions & 0 deletions pokemonterminal/adapter/implementations/Xfce4Terminal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
import time
import subprocess

from pokemonterminal.adapter.base import TerminalAdapterInterface
from shutil import copyfile
from tempfile import mkstemp
from shutil import move
from os import fdopen, remove
from pathlib import Path

class Xfce4Terminal(TerminalAdapterInterface):
@staticmethod
def is_available():
#Get the name of the current terminal
cmd='ps -o comm= -p "$(($(ps -o ppid= -p "$(($(ps -o sid= -p "$$")))")))"'
name=subprocess.check_output(cmd, shell=True)
return b"xfce4" in name

def set_image_file_path(self, image_file_path):
xfce4_config_path = str(Path.home()) + "/.config/xfce4/terminal/terminalrc"

#read xfce4-terminal config file
f = open(xfce4_config_path, "r")
lines = f.readlines()
f.close()
f = open(xfce4_config_path, "w")

#replace the line setting xfce4-terminal's background image
for line in lines:
if "BackgroundImage" not in line:
f.write(line)
else:
f.write("BackgroundImageFile=" + image_file_path + "\n")
f.close()


def clear(self):
os.system("tybg")