def pick(options, header_filter=None, body_filter=None, match_filter=None, **kwargs): if header_filter is None: def header_filter(x): return papis.document.format_doc( papis.config.get('header-format', section='rofi-gui'), x) if len(options) == 1: indices = [0] else: r = rofi.Rofi() indices, key = r.select("Filter: ", [ header_filter(d).replace( papis.config.get("sep", section="rofi-gui"), '\n') for d in options ], **get_options()) r.close() # TODO: Support multiple choice if len(indices) == 0: return [] elif len(indices) > 1: logger.warning("Multiple choices is still not supported!") return options[indices[0]]
def show_user_prompt(action_response: ActionResponseQueryList): assert isinstance(action_response, ActionResponseQueryList) rofi_prompt = rofi.Rofi(len(action_response.items)) rofi_result = rofi_prompt.select(action_response.prompt, action_response.items) return rofi_result
def main(): parser = argparse.ArgumentParser() parser.add_argument('--setup', action='store_true', default=False) parser.add_argument('--mode', '-m', default=list(modes)[0], choices=modes.keys()) args = parser.parse_args() if args.setup: setup() else: client_conf = get_client_conf() oauth = SpotifyOAuth( client_id=client_conf['client_id'], client_secret=client_conf['client_secret'], redirect_uri='http://localhost:8080/', scope= 'user-modify-playback-state app-remote-control streaming user-read-playback-state user-library-read', cache_path=os.path.join(DIR_CONF, 'auth.json')) sp = Spotify(oauth_manager=oauth) rofi_client = rofi.Rofi(rofi_args=['-i']) try: modes[args.mode](sp, rofi_client).run() except UserCancel: print('Cancel...')
def pick(options, header_filter=None, body_filter=None, match_filter=None): if header_filter is None: header_filter = lambda x: papis.utils.format_doc( papis.config.get('header-format', section='rofi-gui'), x) if len(options) == 1: indices = 0 else: r = rofi.Rofi() indices, key = r.select("Select: ", [header_filter(d) for d in options], **get_options()) r.close() # TODO: Support multiple choice if not isinstance(indices, list): indices = [indices] return options[indices[0]]
def ask(self, json): # https://github.com/bcbnz/python-rofi r = rofi.Rofi() winid = int(json["winid"], 10) wtitle = Utils.getWinTitle(winid) wtitleId = "%s[%d]" % (wtitle, winid) prompt = "%s need your attention" % wtitleId actions = dict() message = "Finished %s" % json['cmd'] actions[XwinSessionHandler.Action.Ignore] = "Ignore %s" % wtitleId actions[XwinSessionHandler.Action.Select] = "Select %s" % wtitleId actions[XwinSessionHandler.Action.Remind] = "Remind after 10 mins" options = actions.values() index, key = r.select(prompt, options, message) self.log.warning("index %d, key %d" % (index, key)) return index
def ask(self, json): # https://github.com/bcbnz/python-rofi r = rofi.Rofi() connection = json["connection"] session = json["session"] titleId = "%s[%s]" % (connection, session) prompt = "%s[%s] need your attention" % (connection, session) actions = dict() message = "Finished %s" % json['cmd'] actions[RemoteSshScreenHandler.Action.Ignore] = "Ignore %s" % titleId actions[RemoteSshScreenHandler.Action.Select] = "Select %s" % titleId actions[RemoteSshScreenHandler.Action.Remind] = "Remind after 10 mins" options = actions.values() index, key = r.select(prompt, options, message) self.log.warning("index %d, key %d" % (index, key)) return index
def main(self, documents): self.query_string = '' self.documents = documents key = None indices = None options = get_options() header_format = papis.config.get("header-format", section="rofi-gui") def header_filter(x): return papis.document.format_doc(header_format, x) self.help_message = self.get_help() options.update(self.keys) # Initialize window self.window = rofi.Rofi() while not (key == self.quit_key or key == self.esc_key): indices, key = self.window.select( "Filter: ", [header_filter(d) for d in self.documents], select=indices, **options) if not isinstance(indices, list): indices = [indices] if key == self.edit_key: for i in indices: edit(self.documents[i], editor=papis.config.get('editor')) elif key in [self.open_key, self.open_stay_key]: for i in indices: papis_open(self.documents[i]) if key == self.open_key: return 0 elif key == self.delete_key: for i in indices: self.delete(self.documents[i]) elif key == self.help_key: self.window.error(self.help_message) elif key == self.browse_key: for i in indices: browse(self.documents[i]) elif key == self.normal_window_key: options["normal_window"] ^= True elif key == self.refresh_key: self.refresh() elif key == self.query_key: self.query_string = self.window.text_entry("Query input: ") self.set_docs_from_query()
def __init__(self, debug=False): """Initialize .""" self._rofi = rofi.Rofi() self._libts = libtmux.Server() self._sessions = None self._cur_tmux_s = None self.logger = logging.getLogger(__name__) if debug: self.logger.setLevel(logging.DEBUG) homedir = os.environ.get('HOME') self._cache_f = os.path.join(homedir, '.rft.cache') self._cache = self._load_cache() self._config = self._load_config(os.path.join(homedir, '.rft')) self._register_cur_sessions() if self._config.get('wm') == 'i3': self._wm = i3WM(self._config, logger_lvl = self.logger.getEffectiveLevel()) else: self._wm = None
def giveFocus(self, connection, session): self.log.warning("connection %s, session %s" % (connection, session)) username, server, port = Utils._split_server(connection) if server in ["", "localhost", "127.0.0.1"]: os.system("xterm -e screen -d -m -x %s&" % session) else: self.log.warning("username %s, server %s, port %s" % (username, server, port)) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) result = sock.connect_ex((server, port)) if result == 0: # check here if screen is already attached. os.system( "xterm -e ssh -t -X -o PubkeyAuthentication=yes -o VisualHostKey=no %s screen -d -m -x %s&" % (connection, session)) else: r = rofi.Rofi() r.message("Not accessible.") sock.close()
def main(self, documents): # Set default picker self.documents = documents key = None indices = None options = get_options() header_format = papis.config.get("header-format", section="rofi-gui") header_filter = lambda x: papis.utils.format_doc(header_format, x) self.help_message = self.get_help() options.update(self.keys) # Initialize window self.window = rofi.Rofi() while not (key == self.quit_key or key == self.esc_key): indices, key = self.window.select( "Select: ", [header_filter(d) for d in self.documents], select=indices, **options) if not isinstance(indices, list): indices = [indices] if key == self.edit_key: for i in indices: self.edit(self.documents[i]) elif key in [self.open_key, self.open_stay_key]: for i in indices: self.open(self.documents[i]) options["normal_window"] ^= True if key == self.open_key: return 0 elif key == self.delete_key: for i in indices: self.delete(self.documents[i]) elif key == self.help_key: self.window.error(self.help_message) elif key == self.browse_key: for i in indices: self.browse(self.documents[i]) elif key == self.normal_widnow_key: options["normal_window"] ^= True
#!/usr/bin/python import dbus import rofi # dbus stuff bus = dbus.SessionBus() browser_tabs_object = bus.get_object('org.cubimon.BrowserTabs', '/org/cubimon/BrowserTabs') browser_tabs_interface = dbus.Interface( browser_tabs_object, dbus_interface='org.cubimon.BrowserTabs') get_active_tab_id = browser_tabs_interface.get_dbus_method('activeTabId') rename = browser_tabs_interface.get_dbus_method('rename') # get new name from rofi r = rofi.Rofi() new_name = r.text_entry('Enter new Browser tab name') # rename rename(int(get_active_tab_id()), new_name)
#!/usr/bin/python import i3ipc import rofi import sys import time from time import sleep i3 = i3ipc.Connection() menu = rofi.Rofi() def scratchpad(): for con in i3.get_tree(): if (con.name == "__i3_scratch"): return con def get_windows(): wins = [] names = [] numEntries = 0 for con in scratchpad(): wins += con for con in wins: names.append(con.name) numEntries += 1 return reversed(wins), reversed(names), numEntries wins, names, numEntries = get_windows()