Giter Club home page Giter Club logo

rofi-power-menu's Introduction

Rofi Power Menu Mode

Rofi Power Menu provides a mode for offering basic power menu operations such as shutting down, logging out, rebooting and suspending. By default, it shows all choices and asks for confirmation for irreversible actions. The choices, their order and whether they require confirmation, can be all configured with command-line options. It also shows symbols by default, but this requires a monospace font with good support for symbols, so it can be disabled with --no-symbols.

In contrast to other similar solutions I've found, the power menu is implemented as a rofi mode, not as a stand-alone executable that launches rofi by itself. This makes it possible to combine the script with the full power of how rofi can use modi. For instance, you can have multiple modi available (-modi) or combine multiple modi in one mode (-combi-modi), pass your own themes (-theme) and configurations as CLI flags (e.g., -fullscreen, -sidebar-mode, -matching fuzzy, -location).

There's also a stand-alone script which uses dmenu (or rofi in dmenu mode). It's also a bit easier to use as you don't need to type the small amount of rofi "boilerplate".

Just to give an example, the screenshot below shows Rofi Power Menu launched as:

rofi \
  -show p \
  -modi p:'rofi-power-menu --symbols-font "Symbols Nerd Font Mono"' \
  -font "JetBrains Mono NF 16" \
  -theme Paper \
  -theme-str 'window {width: 8em;} listview {lines: 6;}'

Screenshot of Rofi Power Menu

Install

You can use the script directly from this directory without needing to install it at all. If you want rofi to find it more easily, the script needs to be found in PATH. If you have ~/.local/bin in PATH, you can just copy the script there:

cp rofi-power-menu ~/.local/bin/

Usage

A simple example showing how to launch the power menu:

rofi -show power-menu -modi power-menu:rofi-power-menu

If you didn't install the script in PATH, you need to give the path to the script. If you're running rofi under this directory where the script is, you can run it as follows:

rofi -show power-menu -modi power-menu:./rofi-power-menu

--help

rofi-power-menu - a power menu mode for Rofi

Usage: rofi-power-menu [--choices CHOICES] [--confirm CHOICES]
                       [--choose CHOICE] [--dry-run] [--symbols|--no-symbols]

Use with Rofi in script mode. For instance, to ask for shutdown or reboot:

  rofi -show menu -modi "menu:rofi-power-menu --choices=shutdown/reboot"

Available options:
  --dry-run            Don't perform the selected action but print it to stderr.
  --choices CHOICES    Show only the selected choices in the given order. Use /
                       as the separator. Available choices are lockscreen,
                       logout,suspend, hibernate, reboot and shutdown. By
                       default, all available choices are shown.
  --confirm CHOICES    Require confirmation for the gives choices only. Use / as
                       the separator. Available choices are lockscreen, logout,
                       suspend, hibernate, reboot and shutdown. By default, only
                       irreversible actions logout, reboot and shutdown require
                       confirmation.
  --choose CHOICE      Preselect the given choice and only ask for a
                       confirmation (if confirmation is set to be requested). It
                       is strongly recommended to combine this option with
                       --confirm=CHOICE if the choice wouldn't require
                       confirmation by default. Available choices are
                       lockscreen, logout, suspend, hibernate, reboot and
                       shutdown.
  --[no-]symbols       Show Unicode symbols or not. Requires a font with support
                       for the symbols. Use, for instance, fonts from the
                       Nerdfonts collection. By default, they are shown
  --[no-]text          Show text description or not.
  --symbols-font FONT  Use the given font for symbols. By default, the symbols
                       use the same font as the text. That font is configured
                       with rofi.
  -h,--help            Show this help text.

--choices=CHOICE1/CHOICE2/...

By default, the menu shows all available choices in a particular order. You can control the shown choices and their order by using --choices and listing the desired choices with / as the separator. Available choices are:

  • lockscreen: Lock screen
  • logout: Log out (confirmation asked by default)
  • suspend: Suspend
  • hibernate: Hibernate
  • reboot: Reboot (confirmation asked by default)
  • shutdown: Shutdown (confirmation asked by default)

For instance, to show only shutdown and reboot choices:

rofi -show power-menu -modi "power-menu:./rofi-power-menu --choices=shutdown/reboot"

Or if you want a typical session menu:

rofi -show session-menu -modi "session-menu:./rofi-power-menu --choices=logout/lockscreen"

--confirm=CHOICE1/CHOICE2/...

By default, confirmation is asked for irreversible actions logout, reboot and shutdown. You can choose for which actions you want confirmation (if any) by listing them with --confirm option. For instance, confirmation can be asked only for reboot and shutdown:

rofi -show power-menu -modi "power-menu:./rofi-power-menu --confirm=reboot/shutdown"

If you don't want confirmations for any actions, just give an empty string:

rofi -show power-menu -modi "power-menu:./rofi-power-menu --confirm=''"

--choose=CHOICE

To open just a confirmation dialog for some fixed choice, you can use --choose=CHOICE, where CHOICE can again be one of the choices listed above. You should also require confirmation for that choice if that isn't done by default. For instance, a simple logout confirmation:

rofi -show logout -modi "logout:./rofi-power-menu --choose=logout"

For some choices (e.g., hibernate), confirmation isn't asked by default, so you probably want to ask that in this case:

rofi -show hibernate -modi "hibernate:./rofi-power-menu --choose=hibernate --confirm=hibernate"

If confirmation isn't asked, the action is performed immediately. Although, that's probably not useful, it is possible. However, note that Rofi will still pop up a menu with no options available. It would be nice if Rofi would not appear at all if it wasn't given any choices. This works when running the accompanied stand-alone script dmenu-power-menu.

--[no-]symbols

Disable or enable Unicode symbols/icons/glyphs. They are enabled by default. In order for them to show up correctly, you need a font that supports the used glyphs. It is recommended to use fonts from the Nerdfonts collection. In addition, it is recommended to use a monospace font, otherwise the symbols widths might be messed up. So, for instance, "Symbols Nerd Font Mono", "Iosevka Nerd Font Mono" or "JetBrainsMono NF" are good options.

--dry-run

For debugging and development purposes, you can pass --dry-run flag. Then, the selected action isn't performed but only printed to stderr.

dmenu

There's a stand-alone script dmenu-power-menu that can be used to run the power menu with dmenu (or rofi in dmenu mode if dmenu isn't found). That script takes the same command-line arguments as listed above for the main script rofi-power-menu. The stand-alone script might be easier to use but you cannot pass arguments to dmenu/rofi so their configuration is hardcoded. Also, you need to install rofi-script-to-dmenu.

Copyright

Copyright (c) 2020 Jaakko Luttinen

MIT License

rofi-power-menu's People

Contributors

cyyynthia avatar emar10 avatar jluttine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rofi-power-menu's Issues

Use of `loginctl terminate-session` to logout is apparently nonstandard

When attempting to log out of i3 via loginctl terminate-sesison (as rofi-power-menu currently does), i3 exits with code 1. This is reported as an error by sddm, and also leaves behind an X session with a background image and responsive cursor but no interactable elements, which must be killed via Ctrl+Alt+Bksp.

I originally opened this as an issue on i3, but after further testing, found that Openbox and Awesome behave in the same way when killed by loginctl. Thus, it would appear that terminating a session in this way is not a standard method of logging out, and should probably not be the default configuration for rofi-power-menu. Unfortunately, I'm not sure what an appropriate replacement would be, though I'm also not very experienced in the area of desktop interface standards to begin with.

betterlockscreen and i3lock fail to lock

When I try to execute betterlockscreen or i3lock using this script, I get an error saying "lock failed", however when executing either from terminal they work perfectly fine.

escape key doesnt exit properly

Installed AUR package. I am using hyprland. If I bring up the power menu and then hit escape, the window disappears as it should. However, a background GUI app isn't being brought to the foreground. If I open the power menu again and hit escape, all is well again. Note that I do not have this issue with rofi -show drun.

#.config/hypr/hyprland.conf

$menuPower = rofi -show power-menu -modi power-menu:rofi-power-menu
bind = $mainMod, S, exec, $menuPower

Edit: I'm special. TheS key is bound to another action at the end of the config, separate of the other letter key binds. Please ignore this issue, and thank you for the awesome utility.

Can I use a seperate themec onfig file for the power menu?

Hello!

Sorry if my question sounds stupid, but i am a noob trying to learn/use i3wm. I was curious if i could set a different theme for the rofi-power-menu separated than the my rofi drun menu? Could I point it to a different theme config file?

If so, can I change the text size, window size...etc? Replace the text with big icons?

This app is very nice, so I was just curious! Thank you!

Can't start on Gnome Shell

Hi, I'm trying it under Gnome Shell but I can't get it working since it's missing the XDG_SESSION_ID variable:

/usr/bin/rofi-power-menu: riga 41: XDG_SESSION_ID: variabile non assegnata

๐Ÿ”’ i3lock & betterlockscreen support

I'm basically reopening this issue here #21 since I'm having the exact same problem. Can you please help me to solve it?

image

After applying those changes to the script, I get a error from i3lock, warning that locking wasn't possible, then it stops the screen locking. So strange behavior, isn't it? Anyone can help me?
I'm using i3lock-color because I want to blur my desktop during my screenlock.
Executing the same command on the terminal, works just fine!

   $ i3lock --nofork --color=00000000

`display-power-menu` seems not to work

Launching rofi with the following command:

rofi -show drun -display-power-menu "fdjsfjds"

Causes the following output:
image

It's still named "Power..." not my random name in combi mode (right side).

Execute action after rofi window is closed

Hi,

is it possible to have the action performed after the rofi window is closed?
I have adapted the script to have a utility menu for my desktop with one of the utilities being to take a screenshot and do some processing on that. Of course I would like to take the screenshot without the rofi utility menu open.

Thank you for for the script!

Symbols disappear or change

Symbols disappear or change for seemingly no reason. The -font option changes the font of the text but has no bearing on the symbols.

Example command in README causes error: unrecognized option '--symbols-font'

Using the command provided in your README

rofi \
  -show p \
  -modi p:'rofi-power-menu --symbols-font "Symbols Nerd Font Mono"' \
  -font "JetBrains Mono NF 16" \
  -theme Paper \
  -theme-str 'window {width: 8em;} listview {lines: 6;}'

Returns an error
rofi-power-menu: unrecognized option '--symbols-font'

Removing the single quotes from the 3rd line mitigates this issue.

However, the provided command still does not work as intended. Some symbols are not displayed correctly.
PXL_20230819_165235606

Now I do recognize that this is probably some error on my part but from what I can see everything should be fine.
Using fc-list, one can clearly see that the font used in the example is installed

~ fc-match "Symbols Nerd Font Mono"
SymbolsNerdFontMono-Regular.ttf: "Symbols Nerd Font Mono" "Regular"

Info

  • rofi-power-menu 3.0.1-1 (pacman)
  • ttf-nerd-fonts-symbols-mono 3.0.2-2 (pacman)

No icons

I'm in wayland, I launch rofi-power-menu as:

rofi -show power-menu -modi power-menu:rofi-power-menu -font "JetBrainsMono NF 16" --symbols

but it don't display icons, insted I got \u200e\uF011
I have tested with other fonts whithout sucess. What I'm doing wrong?

Text not visible

The menu launches with invisible text. The following line is a warning printed in the console when running this:

pango_layout_set_markup_with_accel: Attribute 'allow_breaks' is not allowed on the <span> tag on line 1 char 96

Is theme working?

No matter what theme I am using it shows the same default colors. I tried a number of different things.

Icon and text on different line

Thanks for this amazing script.

However, I have one issue that I am not able to get the icon and text on different lines.

In my rofi config, I see some configs where items are shown in grid format, where icon and text are on different lines.

I am unable to replicate the same in this script even if I apply the exact same config.

It seems the icon and text is together passed as text to rofi.

rofi-power-menu works when launched from terminal but not from sxhkd keybind

When using the terminal, i run rofi-power-menu using the following command:

rofi -show power-menu -modi power-menu:rofi-power-menu

and it works just fine. However, the exact same command in sxhkd, when executed with a keybind, returns with the following error:

Failed to execute: 'rofi-power-menu'
Error: Failed to execute child process "rofi-power-menu" (no such file or directory)'

I have also added ./local/bin to my path in .zshrc:

PATH=$PATH:/home/jaami/.local/bin

I'm pretty confused on what is going on here...

Menu translation

Is there a plan to translate the menu entries?
I could offer you a PR if you want.

The prompt will not be displayed if show it with other modes(combi)

For instance:

rofi -show combi -combi-modi drun,window,power -modi combi,power:rofi-power-menu

in the combi list which contains all the modes, if I choose reboot from power, there is a prompt "Yes, reboot/No, cancel", but this prompt is not displayed in mobi list, you have to switch to the power tab to get the prompt.

Wrong icons after updating to Nerd Fonts 3.0.0

I'm using JetBrainsMono Nerd Font. After updating to Nerd Fonts 3.0.0, I'm getting wrong icons for Log out and Suspend:
1

Relevant part of my rofi configuration for rofi-power-menu:

configuration {
  modi: "drun";
  font: "JetBrainsMono Nerd Font 10.5";
}

icons[logout]="\uf842"
icons[suspend]="\uf9b1"

Same in Kitty with JetBrainsMono Nerd Font too.
image

Maybe they should be updated? this can help:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.