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

Restore custom linuxvt palette using /sys/module/vt/parameters #263

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 20 additions & 1 deletion src/ponysay.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,25 @@ def printPony(self, args):
pony = KMS.kms(pony, self.HOME, self.linuxvt)

## If in Linux VT clean the terminal (See info/pdf-manual [Printing in TTY with KMS])
palette = ''
if self.linuxvt:
print('\033[H\033[2J', end='')
pal = []
red = []
with open('/sys/module/vt/parameters/default_red') as f:
red = f.readline().split(',')
f.close()
grn = []
with open('/sys/module/vt/parameters/default_grn') as f:
grn = f.readline().split(',')
f.close()
blu = []
with open('/sys/module/vt/parameters/default_blu') as f:
blu = f.readline().split(',')
f.close()
for i in range(16):
pal.append('\033]P{idx:X}{red:0>2X}{grn:0>2X}{blu:0>2X}'.format(idx = i, red = int(red[i]), grn = int(grn[i]), blu = int(blu[i])))
palette = ''.join(pal)

## Get width truncation and wrapping
widthtruncation = self.__getWidthTruncation()
Expand Down Expand Up @@ -938,7 +955,9 @@ def printPony(self, args):

## Print the output, truncated on the height
self.__printOutput(output)


if self.linuxvt:
print(palette)

def __getSelectedPonies(self, args, selection):
'''
Expand Down