def readConfigCPUFormat(widget, theme_cfg): global Instances id = karamba.readConfigEntry(widget, "id") toptext = karamba.getThemeText(widget, "toptext") #### Begin reading optional settings from [cpuFormat] #### # if one option is missing. Then use defaults # cpu_padding = karamba.readConfigEntry(widget, "cpu_padding") # cpu_decimal_1 = karamba.readConfigEntry(widget, "cpu_decimal_1") # cpu_decimal_0 = karamba.readConfigEntry(widget, "cpu_decimal_0") # hide_0 = karamba.readConfigEntry(widget, "hide_0") # cpu_rem_0 = karamba.readConfigEntry(widget, "cpu_rem_0") # # if cpu_decimal_1: # cpu_more_one = "%0.1f" # if cpu_decimal_0: # cpu_less_one = "%0.1f" showZero = karamba.readConfigEntry(widget, "showZero") if showZero == None: karamba.setMenuConfigOption(widget, "showZero", 0) karamba.writeConfigEntry(widget, "showZero", "false") try: hide_0 = theme_cfg.getboolean( "cpuFormat" , "hide_0" ) if hide_0: Instances[id].cpuHideZero() except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Skipping option."
def menuOptionChanged(widget, key, value): global browser_pid if key == "browser": karamba.setMenuConfigOption(widget, "browser", 0) command = ["kdialog", "--title", "Enter the path to your favorite browser", "--inputbox", "Path to browser", "/usr/bin/mozilla"] browser_pid = karamba.executeInteractive(widget, command)
def readConfigCPUFormat(widget, theme_cfg): global Instances id = karamba.readConfigEntry(widget, "id") toptext = karamba.getThemeText(widget, "toptext") #### Begin reading optional settings from [cpuFormat] #### # if one option is missing. Then use defaults # cpu_padding = karamba.readConfigEntry(widget, "cpu_padding") # cpu_decimal_1 = karamba.readConfigEntry(widget, "cpu_decimal_1") # cpu_decimal_0 = karamba.readConfigEntry(widget, "cpu_decimal_0") # hide_0 = karamba.readConfigEntry(widget, "hide_0") # cpu_rem_0 = karamba.readConfigEntry(widget, "cpu_rem_0") # # if cpu_decimal_1: # cpu_more_one = "%0.1f" # if cpu_decimal_0: # cpu_less_one = "%0.1f" showZero = karamba.readConfigEntry(widget, "showZero") if showZero == None: karamba.setMenuConfigOption(widget, "showZero", 0) karamba.writeConfigEntry(widget, "showZero", "false") try: hide_0 = theme_cfg.getboolean("cpuFormat", "hide_0") if hide_0: Instances[id].cpuHideZero() except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Skipping option."
def readConfigThreading(widget): global Instances id = karamba.readConfigEntry(widget, "id") disableThreading = karamba.readConfigEntry(widget, "disableThreading") if disableThreading == None or disableThreading == "true": karamba.setMenuConfigOption(widget, "disableThreading", 1) karamba.writeConfigEntry(widget, "disableThreading", "true") disableThreading = True else: disableThreading = False Instances[id].setDisableThreading(disableThreading)
def menuOptionChanged(widget, key, value): global g_configGuiPid karamba.setMenuConfigOption(widget, "config_gui", 0) if key == "config_gui": if g_configGuiPid == None: # Launch config GUI gui=os.path.join( Globals().nsCGuiBaseDir, "launchGUI" ) cmd = ["python", gui] g_configGuiPid=karamba.executeInteractive(widget, cmd) else: tools.msgDebug("GUI already running", __name__)
def menuOptionChanged(widget, key, value): global g_configGuiPid karamba.setMenuConfigOption(widget, "config_gui", 0) if key == "config_gui": if g_configGuiPid == None: # Launch config GUI gui = os.path.join(Globals().nsCGuiBaseDir, "launchGUI") cmd = ["python", gui] g_configGuiPid = karamba.executeInteractive(widget, cmd) else: tools.msgDebug("GUI already running", __name__)
def initWidget(widget): # add a menu entry to select language karamba.addMenuConfigOption(widget, "ac_locale", "Select your country") karamba.setMenuConfigOption(widget, "ac_locale", 0) # set the language locale.setlocale(locale.LC_ALL, getLocale(widget)) # Generate calendar calendar.printTop(widget, 0) # calendar.showWeekImage(widget, 0) calendar.showDayMarker(widget, 0) calendar.printDayCaptions(widget, 0) calendar.printCalendar(widget, 0) calendar.colorizeDay(widget, calendar.thisDay, 255, 255, 255)
def createConfigMenus(widget): karamba.addMenuConfigOption(widget, "theme", "Choose theme") karamba.setMenuConfigOption(widget, "theme", 0) karamba.addMenuConfigOption(widget, "showZero", "Show processes where the CPU usage is 0") karamba.addMenuConfigOption(widget, "setCmdJustification", "Set the alignment for the command text") karamba.setMenuConfigOption(widget, "setCmdJustification", 0) karamba.addMenuConfigOption(widget, "setProcOutformat", "Set the column order for the output") karamba.setMenuConfigOption(widget, "setProcOutformat", 0) karamba.addMenuConfigOption(widget, "disableThreading", "Disable Threading")
def menuOptionChanged(widget, key, value): global themePath, theme_dir, chtheme_pid, procoutformat_pid, align_pid chtheme_pid = None procoutformat_pid = None align_pid = None chtheme_cmd = [ 'kdialog', '--title', 'Choose theme', '--radiolist', 'Choose theme' ] align_cmd = [ 'kdialog', '--title', 'Set Alignment', '--radiolist', 'Set the alignment for the command text.', 'left', 'Left', 'off', 'right', 'Right', 'off', 'default', 'Reset to theme default', 'on' ] # padding_cmd = ['kdialog', '--title', 'Set Padding', '--inputbox', 'Set maximum length for the command text. Enter an integer number. The default value for flatgray is 13', '13'] procoutformat_cmd = [ 'kdialog', '--title', 'Set Output format', '--inputbox', 'Set the column order for the output. Syntax is important here. Must include all columns.\n\nType \"default\" to reset to the default.\n\nDefault value is: %(cpu_percent)s %(command)s %(memory)s\n\nExamples: %(memory)s %(command)s %(cpu_percent)s\n%(command)s %(cpu_percent)s %(memory)s', '%(cpu_percent)s %(command)s %(memory)s' ] if key == "theme": listing = [] if themePath[-3:] == "skz": skz_file = zipfile.ZipFile(themePath, 'r') ziplisting = skz_file.namelist() skz_file.close() for member in ziplisting: if member.find(theme_dir) > -1: path = member.split("/") if len(path) == 3 and path[2] == "": listing.append(path[1]) else: listing = os.listdir(themePath + theme_dir) # list the files in themes/ for theme in listing: # kdialog wants 3 parameters per item. # tag is what the value is and item is what is display # not sure about status. so just putting anything there chtheme_cmd.append(theme) # one for tag chtheme_cmd.append(theme) # one for item chtheme_cmd.append("on") # one for status karamba.setMenuConfigOption(widget, "theme", 0) chtheme_pid = karamba.executeInteractive(widget, chtheme_cmd) elif key == "setProcOutformat": karamba.setMenuConfigOption(widget, "setProcOutformat", 0) procoutformat_pid = karamba.executeInteractive(widget, procoutformat_cmd) elif key == "showZero": if value == 1: print "Changing to config to show zeros." karamba.writeConfigEntry(widget, "showZero", "true") else: print "Changing to config to hide zeros." karamba.writeConfigEntry(widget, "showZero", "false") karamba.reloadTheme(widget) elif key == "setCmdJustification": karamba.setMenuConfigOption(widget, "setCmdJustification", 0) align_pid = karamba.executeInteractive(widget, align_cmd) elif key == "disableThreading": if value == 1: print "Disable threading." karamba.writeConfigEntry(widget, "disableThreading", "true") else: print "Enable threading." karamba.writeConfigEntry(widget, "disableThreading", "false") karamba.reloadTheme(widget)
def menuOptionChanged(widget, key, value): global localePid localeSelection = ["kdialog", "--title", "Country Selector", "--radiolist", "Please select your language:", "en_US", "English", "off", "de_DE", "German", "off", "es_ES", "Spanish", "off", "nl_BE", "Dutch", "off", "fr_FR", "French", "off", "fi_FI", "Finnish", "off", "it_IT", "Italian", "off"] if (key == "ac_locale"): karamba.setMenuConfigOption(widget, "ac_locale", 0) localePid = karamba.executeInteractive(widget, localeSelection)
def initWidget(widget): global g_nextCacheRefresh, g_showList, g_showIds, g_cacheExpiration, g_pastDays, g_linesMin, g_linesMax # Pass the widget reference Applet.widget = widget # Init splash splash = Applet().Splash() splash.show() # Create dir structure splash.setText("Checking config dirs...") createConfigDirs() # Read config splash.setText("Reading config...") config = Config() # Check whether we want DEBUG messages enabled or not if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Copy GUI files (if necessary) if Globals().versions['nextShows'] != config.get("main", "version") \ or not "launchGUI" in os.listdir( Globals().nsCGuiBaseDir ): # Init dir structures and copy files splash.setText("Setup GUI...") copyThemeFilesToConfigDir(widget) config.set("main", "version", Globals().versions['nextShows']) # Get other useful infos from config splash.setText("Reading config...") displayType = config.get("display", "type") if displayType == "Fixed": g_linesMax = config.getint("display", "lines_fixed") g_linesMin = g_linesMax else: g_linesMin = config.getint("display", "lines_min") g_linesMax = config.getint("display", "lines_max") g_cacheExpiration = config.getint("misc", "cache_expiration") g_pastDays = config.getint("display", "past_days") applet.colorList = config.getColors() applet.episodeFormatString = config.get( "display", "format") applet.browser = config.get( "misc", "browser") applet.dateFormat = config.get( "display", "date_format") applet.whenFormat = config.getint("misc", "when_format") # Getting the show list splash.setText("Getting show list....") g_showList = config.getShows() # Extract IDs g_showIds = [ show['id'] for show in g_showList ] # Init cache cache.setExpiration( g_cacheExpiration ) cache.showIds = g_showIds # Refresh cache if necessary staledList = cache.getStaledCacheFiles() for id in staledList: for show in g_showList: if show['id'] == id: showName = show['name'] splash.setText("Updating cache: '%s'..." % showName) cache.cacheEpisodeList( id ) # Fetch data to display splash.setText("Filtering episodes...") data = Data() episodeList = data.getEpisodeList( g_showIds, g_pastDays, g_linesMax ) applet.episodeList = episodeList # Close the splash splash.setText("Done!") splash.hide() # Init widget # Fallback (for compatibility reasons) # "[display] theme=" was moved to "[misc] theme=" try: applet.themeName = config.get("misc", "theme") except: applet.themeName = Globals().defaultThemeName numReturnedEpisode = len( episodeList ) if numReturnedEpisode < g_linesMin: themeLines = g_linesMin elif numReturnedEpisode > g_linesMax: themeLines = g_linesMax else: themeLines = numReturnedEpisode applet.themeLines = themeLines applet.drawBackground() applet.printEpisodeList() # Store next cache refresh g_nextCacheRefresh = cache.getNextRefreshTS() # Setup menu entry for config GUI karamba.addMenuConfigOption(widget, "config_gui", "Configure...") karamba.setMenuConfigOption(widget, "config_gui", 0)
def initWidget(widget): global g_nextCacheRefresh, g_showList, g_showIds, g_cacheExpiration, g_pastDays, g_linesMin, g_linesMax # Pass the widget reference Applet.widget = widget # Init splash splash = Applet().Splash() splash.show() # Create dir structure splash.setText("Checking config dirs...") createConfigDirs() # Read config splash.setText("Reading config...") config = Config() # Check whether we want DEBUG messages enabled or not if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Copy GUI files (if necessary) if Globals().versions['nextShows'] != config.get("main", "version") \ or not "launchGUI" in os.listdir( Globals().nsCGuiBaseDir ): # Init dir structures and copy files splash.setText("Setup GUI...") copyThemeFilesToConfigDir(widget) config.set("main", "version", Globals().versions['nextShows']) # Get other useful infos from config splash.setText("Reading config...") displayType = config.get("display", "type") if displayType == "Fixed": g_linesMax = config.getint("display", "lines_fixed") g_linesMin = g_linesMax else: g_linesMin = config.getint("display", "lines_min") g_linesMax = config.getint("display", "lines_max") g_cacheExpiration = config.getint("misc", "cache_expiration") g_pastDays = config.getint("display", "past_days") applet.colorList = config.getColors() applet.episodeFormatString = config.get("display", "format") applet.browser = config.get("misc", "browser") applet.dateFormat = config.get("display", "date_format") applet.whenFormat = config.getint("misc", "when_format") # Getting the show list splash.setText("Getting show list....") g_showList = config.getShows() # Extract IDs g_showIds = [show['id'] for show in g_showList] # Init cache cache.setExpiration(g_cacheExpiration) cache.showIds = g_showIds # Refresh cache if necessary staledList = cache.getStaledCacheFiles() for id in staledList: for show in g_showList: if show['id'] == id: showName = show['name'] splash.setText("Updating cache: '%s'..." % showName) cache.cacheEpisodeList(id) # Fetch data to display splash.setText("Filtering episodes...") data = Data() episodeList = data.getEpisodeList(g_showIds, g_pastDays, g_linesMax) applet.episodeList = episodeList # Close the splash splash.setText("Done!") splash.hide() # Init widget # Fallback (for compatibility reasons) # "[display] theme=" was moved to "[misc] theme=" try: applet.themeName = config.get("misc", "theme") except: applet.themeName = Globals().defaultThemeName numReturnedEpisode = len(episodeList) if numReturnedEpisode < g_linesMin: themeLines = g_linesMin elif numReturnedEpisode > g_linesMax: themeLines = g_linesMax else: themeLines = numReturnedEpisode applet.themeLines = themeLines applet.drawBackground() applet.printEpisodeList() # Store next cache refresh g_nextCacheRefresh = cache.getNextRefreshTS() # Setup menu entry for config GUI karamba.addMenuConfigOption(widget, "config_gui", "Configure...") karamba.setMenuConfigOption(widget, "config_gui", 0)
def menuOptionChanged(widget, key, value): global themePath, theme_dir, chtheme_pid, procoutformat_pid, align_pid chtheme_pid = None procoutformat_pid = None align_pid = None chtheme_cmd = ['kdialog', '--title', 'Choose theme', '--radiolist', 'Choose theme'] align_cmd = ['kdialog', '--title', 'Set Alignment', '--radiolist', 'Set the alignment for the command text.', 'left', 'Left', 'off', 'right', 'Right', 'off', 'default','Reset to theme default', 'on'] # padding_cmd = ['kdialog', '--title', 'Set Padding', '--inputbox', 'Set maximum length for the command text. Enter an integer number. The default value for flatgray is 13', '13'] procoutformat_cmd = ['kdialog', '--title', 'Set Output format', '--inputbox', 'Set the column order for the output. Syntax is important here. Must include all columns.\n\nType \"default\" to reset to the default.\n\nDefault value is: %(cpu_percent)s %(command)s %(memory)s\n\nExamples: %(memory)s %(command)s %(cpu_percent)s\n%(command)s %(cpu_percent)s %(memory)s', '%(cpu_percent)s %(command)s %(memory)s'] if key == "theme": listing = [] if themePath[-3:] == "skz": skz_file = zipfile.ZipFile(themePath, 'r') ziplisting = skz_file.namelist() skz_file.close() for member in ziplisting: if member.find(theme_dir) > -1: path = member.split("/") if len(path) == 3 and path[2] == "": listing.append( path[1] ) else: listing = os.listdir(themePath + theme_dir) # list the files in themes/ for theme in listing: # kdialog wants 3 parameters per item. # tag is what the value is and item is what is display # not sure about status. so just putting anything there chtheme_cmd.append(theme) # one for tag chtheme_cmd.append(theme) # one for item chtheme_cmd.append("on") # one for status karamba.setMenuConfigOption(widget, "theme", 0) chtheme_pid = karamba.executeInteractive(widget, chtheme_cmd) elif key == "setProcOutformat": karamba.setMenuConfigOption(widget, "setProcOutformat", 0) procoutformat_pid = karamba.executeInteractive(widget, procoutformat_cmd) elif key == "showZero": if value == 1: print "Changing to config to show zeros." karamba.writeConfigEntry(widget, "showZero", "true") else: print "Changing to config to hide zeros." karamba.writeConfigEntry(widget, "showZero", "false") karamba.reloadTheme(widget) elif key == "setCmdJustification": karamba.setMenuConfigOption(widget, "setCmdJustification", 0) align_pid = karamba.executeInteractive(widget, align_cmd) elif key == "disableThreading": if value == 1: print "Disable threading." karamba.writeConfigEntry(widget, "disableThreading", "true") else: print "Enable threading." karamba.writeConfigEntry(widget, "disableThreading", "false") karamba.reloadTheme(widget)