From cd4888a5cfc912720f230c3a550526f4428f83b4 Mon Sep 17 00:00:00 2001 From: QC Date: Mon, 21 Jul 2014 21:39:24 +0200 Subject: [PATCH] Fix #65, Fix #63 Allow user to select list of modi's * Add script_dialog, so user can add dialogs using a script. * Add a way to disable modi's * Add -show option. --- Examples/i3_switch_workspaces.sh | 22 +++ Makefile.am | 3 + config/config.c | 3 + doc/rofi-manpage.markdown | 33 ++++- doc/rofi.1 | 49 ++++++- include/dmenu-dialog.h | 2 +- include/rofi.h | 20 ++- include/run-dialog.h | 2 +- include/script-dialog.h | 28 ++++ include/ssh-dialog.h | 2 +- include/textbox.h | 12 +- source/dmenu-dialog.c | 4 +- source/rofi.c | 227 +++++++++++++++++++++++++------ source/run-dialog.c | 4 +- source/script-dialog.c | 201 +++++++++++++++++++++++++++ source/ssh-dialog.c | 4 +- source/xrmoptions.c | 1 + 17 files changed, 544 insertions(+), 73 deletions(-) create mode 100755 Examples/i3_switch_workspaces.sh create mode 100644 include/script-dialog.h create mode 100644 source/script-dialog.c diff --git a/Examples/i3_switch_workspaces.sh b/Examples/i3_switch_workspaces.sh new file mode 100755 index 00000000..a5920567 --- /dev/null +++ b/Examples/i3_switch_workspaces.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ -z $@ ] +then +function gen_workspaces() +{ + i3-msg -t get_workspaces | tr ',' '\n' | grep "name" | sed 's/"name":"\(.*\)"/\1/g' | sort -n +} + + +echo empty; gen_workspaces +else + WORKSPACE=$@ + + if [ x"empty" = x"${WORKSPACE}" ] + then + i3_empty_workspace.sh >/dev/null + elif [ -n "${WORKSPACE}" ] + then + i3-msg workspace "${WORKSPACE}" >/dev/null + fi +fi diff --git a/Makefile.am b/Makefile.am index 9d416647..5e95f8d2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,12 +26,14 @@ rofi_SOURCES=\ source/dmenu-dialog.c\ source/run-dialog.c\ source/ssh-dialog.c\ + source/script-dialog.c\ source/history.c\ config/config.c\ include/rofi.h\ include/run-dialog.h\ include/ssh-dialog.h\ include/dmenu-dialog.h\ + include/script-dialog.h\ include/xrmoptions.h\ include/history.h\ include/textbox.h @@ -66,6 +68,7 @@ EXTRA_DIST=\ $(man1_MANS)\ $(markdown_FILES)\ $(markdown_SC_FILES)\ + Examples/i3_switch_workspaces.sh\ INSTALL.md ## diff --git a/config/config.c b/config/config.c index 54590735..7037599d 100644 --- a/config/config.c +++ b/config/config.c @@ -29,6 +29,9 @@ #include "rofi.h" Settings config = { + // List of enabled switchers. + // -switchers + .switchers = "window,run,ssh", // Set the default window opacity. // This option only works when running a composite manager. // -o diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index d1a3599b..f2364edd 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -14,11 +14,11 @@ SYNOPSIS [ -terminal *terminal* ] [ -loc *position* ] [ -hmode ] [ -fixed-num-lines ] [ -padding *padding* ] [ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ] [ -ssh-set-title *true|false* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump-xresources ] -[ -disable-history ] [ -levenshtein-sort ] +[ -disable-history ] [ -levenshtein-sort ] [ -show *mode* ] [ -switcher *mode1,mode2* ] DESCRIPTION ----------- -`rofi` is an X11 popup window switcher. A list is displayed center-screen showing open window titles, WM_CLASS, and desktop number. +`rofi` is an X11 popup window switcher. A list is displayed center-screen showing open window titles, WM_CLASS, and desktop number. The user may filter the list by typing, navigate with Up/Down or Tab keys, and select a window with Return (Enter). Escape cancels. License @@ -219,11 +219,38 @@ OPTIONS When searching sort the result based on levenshtein distance. +`-show` *mode* + + Open rofi in a certain mode. + + For example to show the run-dialog: + + rofi -show run + + This function deprecates -rnow,-snow and -now + +`-switchers` *mode1,mode1* + + Give a comma separated list of modes to enable, in what order. + + For example to only show the run and ssh dialog (in that order): + + rofi -switchers "run,ssh" -show run + + Custom modes can be added using the internal 'script' mode. Each mode has two parameters: + + :