├── README.md ├── config.sample ├── i3-color-rofi ├── rofi-power ├── rofi-power.png └── rofi-virtualbox └── rofi-virtualbox /README.md: -------------------------------------------------------------------------------- 1 | # Rofi Tools 2 | 3 | Tools for and with [rofi](https://github.com/DaveDavenport/rofi). 4 | 5 | Please have a look at [rofi-scripts](https://github.com/carnager/rofi-scripts) 6 | as well. 7 | 8 | ## i3-color-rofi 9 | 10 | Fetches your current i3 wm colors and provides an options string to 11 | color rofi similar to i3. Currently only supports rofi before V1.0.0. 12 | 13 | ### Usage 14 | 15 | Append it to your rofi command line: 16 | 17 | rofi $(i3-color-rofi) 18 | 19 | *i3-color-rofi* generates an options string, so the resulting line may be: 20 | 21 | rofi -show run -bg #222222 -fg #888888 -hlbg #285577 -hlfg #ffffff 22 | 23 | ### TODO 24 | 25 | * compatibility with V1.0.0 26 | * use font from i3's configuration 27 | * improve colors usage 28 | 29 | ## rofi-power 30 | 31 | Provides a menu to call systemctl for shutdown, reboot, suspend etc. It also 32 | shows an entry to exit the window manager if you provide an exit command. 33 | If suspend or hibernate is selected then i3lock is called to have the screen 34 | locked after waking up the system, if USE_LOCKER is set to 'true' in the config file. 35 | You can also change the program to be used as the screen locker by modifying the 36 | variable LOCKER. 37 | 38 | ![rofi-power](rofi-power.png) 39 | 40 | ### Usage 41 | 42 | Copy the *config.sample* file to *$HOME/.config/rofi-power/config* and customize it as you like. 43 | 44 | Then run *rofi-power* and append an exit command, for i3, for example: 45 | 46 | rofi-power "i3-msg exit" 47 | 48 | You can use it with herbstluftwm as well: 49 | 50 | rofi-power "herbstclient quit" 51 | 52 | ## rofi-virtualbox 53 | 54 | Provides a menu to start, power-off, clone, delete etc. virtualbox machines. You select the machine first and the 55 | action to be executed afterwards. 56 | 57 | ### TODO 58 | 59 | * config file 60 | * pause machine 61 | * better way of handling options and corresponding functions - like boosta 62 | 63 | # License 64 | 65 | All tools are released under the terms of the GNU General Public License v2: 66 | 67 | [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt](http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt) 68 | -------------------------------------------------------------------------------- /config.sample: -------------------------------------------------------------------------------- 1 | # configuration for rofi-power tool 2 | LAUNCHER="rofi -width 30 -dmenu -i -p rofi-power" 3 | USE_LOCKER="false" 4 | LOCKER="i3lock" 5 | -------------------------------------------------------------------------------- /i3-color-rofi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Fetches the current i3 wm colors and provides an options string to color rofi 4 | # Usage: rofi $(i3-color-rofi) 5 | # by Oliver Kraitschy - http://okraits.de 6 | 7 | from os import getenv 8 | 9 | # SETTINGS 10 | config_path = getenv("HOME") + "/.i3/config" 11 | 12 | # variables 13 | config_file = None 14 | lines = None 15 | normal_bg = None 16 | normal_fg = None 17 | selected_bg = None 18 | selected_fg = None 19 | normal_bg_var = False 20 | normal_fg_var = False 21 | selected_bg_var = False 22 | selected_fg_var = False 23 | cmd_string = "" 24 | 25 | if __name__ == "__main__": 26 | 27 | # open config file 28 | try: 29 | config_file = open(config_path, "r") 30 | except IOError: 31 | print("Error: i3 config file could not be opened.") 32 | exit(1) 33 | # read all lines into a list 34 | lines = config_file.readlines() 35 | config_file.close() 36 | 37 | # loop over lines and find matches 38 | for line in lines: 39 | cols = line.split() 40 | 41 | # for all lines not empty 42 | if len(cols) > 0: 43 | # normal background 44 | if cols[0] == "client.unfocused": 45 | normal_bg = cols[2] 46 | if normal_bg[0] == "$": 47 | normal_bg_var = True 48 | # normal foreground 49 | normal_fg = cols[3] 50 | if normal_fg[0] == "$": 51 | normal_fg_var = True 52 | # selected background 53 | if cols[0] == "client.focused": 54 | selected_bg = cols[2] 55 | if selected_bg[0] == "$": 56 | selected_bg_var = True 57 | # selected foreground 58 | selected_fg = cols[3] 59 | if selected_fg[0] == "$": 60 | selected_fg_var = True 61 | 62 | # at least one variable was used, we need to find the real values 63 | if normal_bg_var or normal_fg_var or selected_bg_var or selected_fg_var: 64 | for line in lines: 65 | cols = line.split() 66 | 67 | # for all lines starting with "set" 68 | if len(cols) > 0 and cols[0] == "set": 69 | if normal_bg_var and cols[1] == normal_bg: 70 | normal_bg = cols[2] 71 | if normal_fg_var and cols[1] == normal_fg: 72 | normal_fg = cols[2] 73 | if selected_bg_var and cols[1] == selected_bg: 74 | selected_bg = cols[2] 75 | if selected_fg_var and cols[1] == selected_fg: 76 | selected_fg = cols[2] 77 | 78 | if normal_bg is not None: 79 | cmd_string += "-bg " + normal_bg + " " 80 | if normal_fg is not None: 81 | cmd_string += "-fg " + normal_fg + " " 82 | if selected_bg is not None: 83 | cmd_string += "-hlbg " + selected_bg + " " 84 | if selected_fg is not None: 85 | cmd_string += "-hlfg " + selected_fg + " " 86 | print(cmd_string) 87 | exit(0) 88 | -------------------------------------------------------------------------------- /rofi-power: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # rofi-power 4 | # Use rofi to call systemctl for shutdown, reboot, etc 5 | 6 | # 2016 Oliver Kraitschy - http://okraits.de 7 | 8 | OPTIONS="Reboot system\nPower-off system\nSuspend system\nHibernate system" 9 | 10 | # source configuration or use default values 11 | if [ -f $HOME/.config/rofi-power/config ]; then 12 | source $HOME/.config/rofi-power/config 13 | else 14 | LAUNCHER="rofi -width 30 -dmenu -i -p rofi-power" 15 | USE_LOCKER="false" 16 | LOCKER="i3lock" 17 | fi 18 | 19 | # Show exit wm option if exit command is provided as an argument 20 | if [ ${#1} -gt 0 ]; then 21 | OPTIONS="Exit window manager\n$OPTIONS" 22 | fi 23 | 24 | option=`echo -e $OPTIONS | $LAUNCHER | awk '{print $1}' | tr -d '\r\n'` 25 | if [ ${#option} -gt 0 ] 26 | then 27 | case $option in 28 | Exit) 29 | eval $1 30 | ;; 31 | Reboot) 32 | systemctl reboot 33 | ;; 34 | Power-off) 35 | systemctl poweroff 36 | ;; 37 | Suspend) 38 | $($USE_LOCKER) && "$LOCKER"; systemctl suspend 39 | ;; 40 | Hibernate) 41 | $($USE_LOCKER) && "$LOCKER"; systemctl hibernate 42 | ;; 43 | *) 44 | ;; 45 | esac 46 | fi 47 | -------------------------------------------------------------------------------- /rofi-power.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okraits/rofi-tools/46beba214c3341e935560532293633896f49f828/rofi-power.png -------------------------------------------------------------------------------- /rofi-virtualbox/rofi-virtualbox: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # rofi-virtualbox: manage virtualbox machines with rofi 4 | 5 | OPTIONS="Start machine\nPower-off machine\nClone machine\nDelete machine" 6 | 7 | # function definitions 8 | ###################### 9 | 10 | function vmsList() 11 | { 12 | vboxmanage list vms | awk -F '"' '{print $2}' 13 | #vboxmanage list runningvms | awk -F '"' '{print "Running: "$2}' 14 | } 15 | 16 | function startVM() 17 | { 18 | vboxmanage startvm "$1" --type headless 19 | } 20 | 21 | function poweroffVM() 22 | { 23 | vboxmanage controlvm "$1" acpipowerbutton --type headless 24 | } 25 | 26 | function cloneVM() 27 | { 28 | vboxmanage clonevm "$1" --mode machine --register --options keepallmacs 29 | } 30 | 31 | function deleteVM() 32 | { 33 | vboxmanage unregistervm "$1" --delete 34 | } 35 | 36 | # script execution starts here 37 | ############################## 38 | 39 | LAUNCHER="rofi -dmenu -i -l 40 -p" 40 | 41 | while true 42 | do 43 | # select machine to control 44 | vm=$(vmsList | $LAUNCHER 'Select machine') 45 | retval=$? 46 | [ $retval -ne 0 ] && exit $retval 47 | # select action to be executed 48 | option=$(echo -e $OPTIONS | $LAUNCHER 'Select action') 49 | retval=$? 50 | [ $retval -ne 0 ] && exit $retval 51 | case "$option" in 52 | "Start machine") 53 | startVM "$vm" 54 | ;; 55 | "Power-off machine") 56 | poweroffVM "$vm" 57 | ;; 58 | "Clone machine") 59 | cloneVM "$vm" 60 | ;; 61 | "Delete machine") 62 | deleteVM "$vm" 63 | ;; 64 | *) 65 | exit 1 66 | ;; 67 | esac 68 | done 69 | --------------------------------------------------------------------------------