def get_theme(name: Optional[str]) -> Optional[str]: if name is not None: return name if platform.system() == "Linux": try: import xrp # type: ignore Xresources_path = os.path.join(os.environ["HOME"], ".Xresources") if os.path.exists(Xresources_path): Xresources = xrp.parse_file(Xresources_path) if "*TtkTheme" in Xresources.resources: return Xresources.resources["*TtkTheme"] if "*TkTheme" in Xresources.resources: return Xresources.resources["*TkTheme"] return "clam" except Exception as e: logger.warning("Error loading themes: " + str(e)) return None
brightness_up = 'light -A 5' brightness_down = 'light -U 5' def reload_screen(self): call(self.autorandr) call(self.fehbg) def get_watson_status(self): w_stat = check_output(['watson', 'status']) return w_stat.decode("utf-8").replace('\n', '') commands = Commands() xresources = path.realpath(getenv('HOME') + '/.Xresources') result = xrp.parse_file(xresources, 'utf-8') font_data = result.resources['*.font'].split(':') FONT = font_data[0] FONT_SIZE = int(font_data[1].split('=')[1]) color_data = json.loads(open(getenv('HOME')+'/.cache/wal/colors.json').read()) # BLACK = color_data['colors']['color0'] # BLACK = "#15181a" BLACK = "#1A1C1D" RED = color_data['colors']['color1'] GREEN = color_data['colors']['color2'] YELLOW = color_data['colors']['color3'] BLUE = color_data['colors']['color4'] MAGENTA = color_data['colors']['color5'] CYAN = color_data['colors']['color6'] WHITE = color_data['colors']['color7']
def main(): file_name = str(pathlib.Path.home()) + '/.Xresources' result = xrp.parse_file(file_name, encoding='utf-8') print(result.resources['*.foreground']) print('test')
import xrp startpage = 'https://marea.tk/startpage' xr = xrp.parse_file('/home/marea/.xcolors/sayo-dark', None).definitions config.load_autoconfig(True) c.auto_save.session = True # Start flavours # base16-qutebrowser (https://github.com/theova/base16-qutebrowser) # Base16 qutebrowser template by theova # Generated scheme by Flavours base00 = "#262626" base01 = "#474747" base02 = "#686868" base03 = "#898989" base04 = "#aaaaaa" base05 = "#cbcbcb" base06 = "#d3d3d3" base07 = "#dadada" base08 = "#976e6e" base09 = "#4e854e" base0A = "#9c6e4f" base0B = "#a162a1" base0C = "#787878" base0D = "#787878" base0E = "#787878" base0F = "#787878" # set qutebrowser colors
def __init__(self): info('initializing UltraTrace') default_ttktheme = "clam" # alt, clam, classic, default # do the normal Tk init stuff if util.get_platform() == 'Linux': try: info(' - loading platform-specific enhancements for Linux') import xrp # pip3 install xparser from pathlib import Path XresPath = os.path.join(str(Path.home()), '.Xresources') if os.path.isfile(XresPath) or os.path.islink(XresPath): info(" - found .Xresources file: {}".format(XresPath)) Xresources = xrp.parse_file(XresPath, encoding="utf8") #info("Opened .Xresources file {}".format(XresPath)) if '*TtkTheme' in Xresources.resources: ttktheme = Xresources.resources['*TtkTheme'] if ttktheme in THEMES: info(" - setting Linux Ttk theme to {}".format( ttktheme)) else: warn( " - Ttk theme {} specified ~/.Xresources not available, defaulting to {}" .format(ttktheme, default_ttktheme)) ttktheme = default_ttktheme elif '*TkTheme' in Xresources.resources: ttktheme = Xresources.resources['*TkTheme'] info(" - setting Linux Tk theme to {}".format( ttktheme)) else: ttktheme = default_ttktheme info( " - falling back to default Linux Tk theme: {}. You can set your theme to something else by adding a line like \"*TkTheme: alt\" or \"*TtkTheme: arc\" to ~/.Xresources" .format(ttktheme)) else: ttktheme = "clam" # alt, clam, classic, default info( " - no ~/.Xresources file found; falling back to default Linux Tk theme: {}. You can set your theme to something else by adding a line like \"*TkTheme: alt\" or \"*TtkTheme: arc\" to ~/.Xresources" .format(ttktheme)) super().__init__(theme=ttktheme) except Exception as e: error( "Crash while loading .Xresources file or initialising T(t)k theme", e) super().__init__() else: super().__init__() self.title('UltraTrace') # check if we were passed a command line argument parser = argparse.ArgumentParser(prog='UltraTrace') parser.add_argument( 'path', help= 'path (unique to a participant) where subdirectories contain raw data', default=None, nargs='?') args = parser.parse_args() # initialize data module self.Data = modules.Metadata(self, args.path) # initialize the main app widgets self.setWidgetDefaults() self.buildWidgetSkeleton() # initialize other modules self.Control = modules.Control(self) self.Trace = modules.Trace(self) self.Dicom = modules.Dicom(self) self.Audio = modules.Playback(self) self.TextGrid = modules.TextGrid(self) self.Spectrogram = modules.Spectrogram(self) self.Search = modules.Search(self) info(' - loading widgets') self.filesUpdate() # self.framesUpdate() # self.TextGrid.startup() #NOTE why does modules.TextGrid have to reset a second time? Is there a more economical way to do this? # to deal with resize handler being called multiple times # in a single window resize self.isResizing = False self.oldwidth = self.winfo_width() self.after(300, self.afterstartup)
#!/usr/bin/python import sys import json import xrp x = xrp.parse_file(sys.argv[1], 'utf-8') colors = { f'color{n}': [j for i, j in x.resources.items() if i.endswith(f'color{n}')][0] for n in range(16) } special = { k: [j for i, j in x.resources.items() if i.endswith(k)][0] for k in ['foreground', 'background', 'cursor'] } out = {'colors': colors, 'special': special} with open(sys.argv[2], 'w') as f: json.dump(out, f)
def __init__(self): info('initializing UltraTrace') # do the normal Tk init stuff if util.get_platform() == 'Linux': try: info('Loading platform-specific enhancements for Linux') import xrp # pip3 install xparser from pathlib import Path Xresources = xrp.parse_file( os.path.join(str(Path.home()), '.Xresources')) if '*TtkTheme' in Xresources.resources: ttktheme = Xresources.resources['*TtkTheme'] info("Setting Linux Ttk theme to {}".format(ttktheme)) elif '*TkTheme' in Xresources.resources: ttktheme = Xresources.resources['*TkTheme'] info("Setting Linux Tk theme to {}".format(ttktheme)) else: ttktheme = "clam" # alt, clam, classic, default info("Falling back to default Linux Tk theme: {}".format( ttktheme)) super().__init__(theme=ttktheme) except Exception as e: error(e) super().__init__() else: super().__init__() self.title('UltraTrace') # check if we were passed a command line argument parser = argparse.ArgumentParser(prog='UltraTrace') parser.add_argument( 'path', help= 'path (unique to a participant) where subdirectories contain raw data', default=None, nargs='?') args = parser.parse_args() # initialize data module self.Data = modules.Metadata(self, args.path) # initialize the main app widgets self.setWidgetDefaults() self.buildWidgetSkeleton() # initialize other modules self.Control = modules.Control(self) self.Trace = modules.Trace(self) self.Dicom = modules.Dicom(self) self.Audio = modules.Playback(self) self.TextGrid = modules.TextGrid(self) self.Spectrogram = modules.Spectrogram(self) self.Search = modules.Search(self) info(' - loading widgets') self.filesUpdate() # self.framesUpdate() # self.TextGrid.startup() #NOTE why does modules.TextGrid have to reset a second time? Is there a more economical way to do this? # to deal with resize handler being called multiple times # in a single window resize self.isResizing = False self.oldwidth = self.winfo_width() self.after(300, self.afterstartup)