Skip to content

Commit 7406dea

Browse files
committedMay 3, 2023
Add --symbols-font option
1 parent aa14edb commit 7406dea

File tree

3 files changed

+70
-48
lines changed

3 files changed

+70
-48
lines changed
 

‎README.md

+34-25
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ also a bit easier to use as you don't need to type the small amount of rofi
2424
Just to give an example, the screenshot below shows Rofi Power Menu launched as:
2525

2626
```
27-
rofi -show p -modi p:rofi-power-menu \
27+
rofi -show p -modi p:'rofi-power-menu --symbols-font "Symbols Nerd Font Mono"' \
2828
-theme Paper \
29+
-font "JetBrains Mono NF 16"
30+
rofi \
31+
-show p \
32+
-modi p:'./rofi-power-menu --symbols-font "Symbols Nerd Font Mono"' \
2933
-font "JetBrains Mono NF 16" \
30-
-width 20 \
31-
-lines 6
34+
-theme Paper \
35+
-theme-str 'window {width: 8em;} listview {lines: 6;}'
3236
```
3337

3438
![Screenshot of Rofi Power Menu](./screenshot.png)
@@ -76,27 +80,31 @@ Use with Rofi in script mode. For instance, to ask for shutdown or reboot:
7680
rofi -show menu -modi "menu:rofi-power-menu --choices=shutdown/reboot"
7781
7882
Available options:
79-
--dry-run Don't perform the selected action but print it to stderr.
80-
--choices CHOICES Show only the selected choices in the given order. Use /
81-
as the separator. Available choices are lockscreen, logout,
82-
suspend, hibernate, reboot and shutdown. By default, all
83-
available choices are shown.
84-
--confirm CHOICES Require confirmation for the gives choices only. Use / as
85-
the separator. Available choices are lockscreen, logout,
86-
suspend, hibernate, reboot and shutdown. By default, only
87-
irreversible actions logout, reboot and shutdown require
88-
confirmation.
89-
--choose CHOICE Preselect the given choice and only ask for a confirmation
90-
(if confirmation is set to be requested). It is strongly
91-
recommended to combine this option with --confirm=CHOICE
92-
if the choice wouldn't require confirmation by default.
93-
Available choices are lockscreen, logout, suspend,
94-
hibernate, reboot and shutdown.
95-
--[no-]symbols Show Unicode symbols or not. Requires a font with support
96-
for the symbols. Use, for instance, fonts from the
97-
Nerdfonts collection. By default, they are shown
98-
--[no-]text Show text description or not.
99-
-h,--help Show this help text.
83+
--dry-run Don't perform the selected action but print it to stderr.
84+
--choices CHOICES Show only the selected choices in the given order. Use /
85+
as the separator. Available choices are lockscreen,
86+
logout,suspend, hibernate, reboot and shutdown. By
87+
default, all available choices are shown.
88+
--confirm CHOICES Require confirmation for the gives choices only. Use / as
89+
the separator. Available choices are lockscreen, logout,
90+
suspend, hibernate, reboot and shutdown. By default, only
91+
irreversible actions logout, reboot and shutdown require
92+
confirmation.
93+
--choose CHOICE Preselect the given choice and only ask for a
94+
confirmation (if confirmation is set to be requested). It
95+
is strongly recommended to combine this option with
96+
--confirm=CHOICE if the choice wouldn't require
97+
confirmation by default. Available choices are
98+
lockscreen, logout, suspend, hibernate, reboot and
99+
shutdown.
100+
--[no-]symbols Show Unicode symbols or not. Requires a font with support
101+
for the symbols. Use, for instance, fonts from the
102+
Nerdfonts collection. By default, they are shown
103+
--[no-]text Show text description or not.
104+
--symbols-font FONT Use the given font for symbols. By default, the symbols
105+
use the same font as the text. That font is configured
106+
with rofi.
107+
-h,--help Show this help text.
100108
```
101109

102110

@@ -176,7 +184,8 @@ order for them to show up correctly, you need a font that supports the used
176184
glyphs. It is recommended to use fonts from the [Nerdfonts
177185
collection](https://www.nerdfonts.com/). In addition, it is recommended to use a
178186
monospace font, otherwise the symbols widths might be messed up. So, for
179-
instance, "Iosevka Nerd Font Mono" or "JetBrainsMono NF" are good options.
187+
instance, "Symbols Nerd Font Mono", "Iosevka Nerd Font Mono" or "JetBrainsMono
188+
NF" are good options.
180189

181190

182191
### `--dry-run`

‎rofi-power-menu

+36-23
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function check_valid {
6868
}
6969

7070
# Parse command-line options
71-
parsed=$(getopt --options=h --longoptions=help,dry-run,confirm:,choices:,choose:,symbols,no-symbols,text,no-text --name "$0" -- "$@")
71+
parsed=$(getopt --options=h --longoptions=help,dry-run,confirm:,choices:,choose:,symbols,no-symbols,text,no-text,symbols-font: --name "$0" -- "$@")
7272
if [ $? -ne 0 ]; then
7373
echo 'Terminating...' >&2
7474
exit 1
@@ -88,27 +88,31 @@ while true; do
8888
echo " rofi -show menu -modi \"menu:rofi-power-menu --choices=shutdown/reboot\""
8989
echo
9090
echo "Available options:"
91-
echo " --dry-run Don't perform the selected action but print it to stderr."
92-
echo " --choices CHOICES Show only the selected choices in the given order. Use / "
93-
echo " as the separator. Available choices are lockscreen, logout,"
94-
echo " suspend, hibernate, reboot and shutdown. By default, all"
95-
echo " available choices are shown."
96-
echo " --confirm CHOICES Require confirmation for the gives choices only. Use / as"
97-
echo " the separator. Available choices are lockscreen, logout,"
98-
echo " suspend, hibernate, reboot and shutdown. By default, only"
99-
echo " irreversible actions logout, reboot and shutdown require"
100-
echo " confirmation."
101-
echo " --choose CHOICE Preselect the given choice and only ask for a confirmation"
102-
echo " (if confirmation is set to be requested). It is strongly"
103-
echo " recommended to combine this option with --confirm=CHOICE"
104-
echo " if the choice wouldn't require confirmation by default."
105-
echo " Available choices are lockscreen, logout, suspend,"
106-
echo " hibernate, reboot and shutdown."
107-
echo " --[no-]symbols Show Unicode symbols or not. Requires a font with support"
108-
echo " for the symbols. Use, for instance, fonts from the"
109-
echo " Nerdfonts collection. By default, they are shown"
110-
echo " --[no-]text Show text description or not."
111-
echo " -h,--help Show this help text."
91+
echo " --dry-run Don't perform the selected action but print it to stderr."
92+
echo " --choices CHOICES Show only the selected choices in the given order. Use /"
93+
echo " as the separator. Available choices are lockscreen,"
94+
echo " logout,suspend, hibernate, reboot and shutdown. By"
95+
echo " default, all available choices are shown."
96+
echo " --confirm CHOICES Require confirmation for the gives choices only. Use / as"
97+
echo " the separator. Available choices are lockscreen, logout,"
98+
echo " suspend, hibernate, reboot and shutdown. By default, only"
99+
echo " irreversible actions logout, reboot and shutdown require"
100+
echo " confirmation."
101+
echo " --choose CHOICE Preselect the given choice and only ask for a"
102+
echo " confirmation (if confirmation is set to be requested). It"
103+
echo " is strongly recommended to combine this option with"
104+
echo " --confirm=CHOICE if the choice wouldn't require"
105+
echo " confirmation by default. Available choices are"
106+
echo " lockscreen, logout, suspend, hibernate, reboot and"
107+
echo " shutdown."
108+
echo " --[no-]symbols Show Unicode symbols or not. Requires a font with support"
109+
echo " for the symbols. Use, for instance, fonts from the"
110+
echo " Nerdfonts collection. By default, they are shown"
111+
echo " --[no-]text Show text description or not."
112+
echo " --symbols-font FONT Use the given font for symbols. By default, the symbols"
113+
echo " use the same font as the text. That font is configured"
114+
echo " with rofi."
115+
echo " -h,--help Show this help text."
112116
exit 0
113117
;;
114118
"--dry-run")
@@ -147,6 +151,10 @@ while true; do
147151
showtext=false
148152
shift 1
149153
;;
154+
"--symbols-font")
155+
symbols_font="$2"
156+
shift 2
157+
;;
150158
"--")
151159
shift
152160
break
@@ -168,7 +176,12 @@ fi
168176
# configure them in the future.
169177

170178
function write_message {
171-
icon="<span font_size=\"medium\">$1</span>"
179+
if [ -z ${symbols_font+x} ];
180+
then
181+
icon="<span font_size=\"medium\">$1</span>"
182+
else
183+
icon="<span font=\"${symbols_font}\" font_size=\"medium\">$1</span>"
184+
fi
172185
text="<span font_size=\"medium\">$2</span>"
173186
if [ "$showsymbols" = "true" ]
174187
then

‎screenshot.png

12.6 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.