diff --git a/bin/rofile b/bin/rofile index c2de4c8..482bcac 100755 --- a/bin/rofile +++ b/bin/rofile @@ -3,12 +3,14 @@ # check args prog="${0##*/}" -usage="Usage: ${0##*/} PROFILE [ARGS] +usage="Usage: ${0##*/} [args] - Run rofi with arguments taken from PROFILE's environment variables. - Any additional ARGS are passed to rofi as well. + Run rofi with arguments determined by . Any additional + are also passed to rofi. - When invoked as '$prog foo bar baz', $prog runs + Profile arguments are taken from environment variables and from + ~/.config/rofi/profile.conf . When invoked as '$prog foo bar baz', + $prog runs rofi -theme-str \"\$ROFI_FOO_THEMESTR\" \$ROFI_FOO_ARGS bar baz " @@ -24,6 +26,10 @@ fi profile="$1" shift +# read config +config="${XDG_CONFIG_HOME-$HOME/.config}/rofi/profile.conf" +[[ -f "$config" ]] && . "$config" + # look up environment variables based on profile profile="${profile^^}" profile="${profile//[^A-Za-z0-9_]/_}" diff --git a/doc/rofile.1 b/doc/rofile.1 index e7db0ac..9c04b8b 100644 --- a/doc/rofile.1 +++ b/doc/rofile.1 @@ -2,12 +2,12 @@ .\" Title: rofile .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.17 -.\" Date: 2022-05-22 +.\" Date: 2022-05-23 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "ROFILE" "1" "2022-05-22" "\ \&" "\ \&" +.TH "ROFILE" "1" "2022-05-23" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -28,16 +28,18 @@ . LINKSTYLE blue R < > .\} .SH "NAME" -rofile \- Use environment variables as rofi configuration. +rofile \- Configurable rofi profiles. .SH "SYNOPSIS" .sp \fIrofile\fP [args] .SH "DESCRIPTION" .sp -Runs rofi with arguments taken from \fIprofile\(cqs\fP environment variables. +Runs rofi with arguments determined by \fIprofile\fP. Any additional \fIargs\fP are also passed to rofi. .sp -When invoked as \fIrofile foo bar baz\fP, rofile runs +Profile arguments are read from environment variables and from +~/.config/rofi/profile.conf . +When invoked as \fI$prog foo bar baz\fP, rofile runs .sp .if n .RS 4 .nf @@ -48,14 +50,13 @@ rofi \-theme\-str "$ROFI_FOO_THEMESTR" $ROFI_FOO_ARGS bar baz .if n .RE .SH "EXAMPLES" .sp -If you have these environment variables: +If you have these variables defined in ~/.config/rofi/profile.conf .sp .if n .RS 4 .nf .fam C -ROFI_BLEZZ_ARGS=\*(Aq\-show blezz \-modi blezz \-auto\-select \-matching normal \-blezz\-config\*(Aq +ROFI_BLEZZ_ARGS=\*(Aq\-show blezz \-modi blezz \-auto\-select \-matching normal \-blezz\-directory\*(Aq ROFI_BLEZZ_THEMESTR=\*(Aqentry {placeholder:"Press hotkey";}\*(Aq -export ROFI_BLEZZ_ARGS ROFI_BLEZZ_THEMESTR .fam .fi .if n .RE @@ -65,7 +66,7 @@ Then this: .if n .RS 4 .nf .fam C -rofile blezz ~/.config/blezz/content +rofile blezz Macro .fam .fi .if n .RE @@ -76,8 +77,8 @@ is the same as this: .nf .fam C rofi \-theme\-str \*(Aqentry {placeholder:"Press hotkey";}\*(Aq \(rs - \-show blezz \-modi blezz \-auto\-select \-matching normal \-blezz\-config \(rs - ~/.config/blezz/content + \-show blezz \-modi blezz \-auto\-select \-matching normal \-blezz\-directory \(rs + Macro .fam .fi .if n .RE diff --git a/doc/rofile.1.html b/doc/rofile.1.html index 0937d3d..b049a9b 100644 --- a/doc/rofile.1.html +++ b/doc/rofile.1.html @@ -29,7 +29,7 @@

rofile(1)

Name

-

rofile - Use environment variables as rofi configuration.

+

rofile - Configurable rofi profiles.

@@ -41,9 +41,11 @@

Synopsis

Description

-

Runs rofi with arguments taken from profile’s environment variables. +

Runs rofi with arguments determined by profile. Any additional args are also passed to rofi.

-

When invoked as rofile foo bar baz, rofile runs

+

Profile arguments are read from environment variables and from +~/.config/rofi/profile.conf . +When invoked as $prog foo bar baz, rofile runs

rofi -theme-str "$ROFI_FOO_THEMESTR" $ROFI_FOO_ARGS bar baz
@@ -53,24 +55,23 @@

Description

Examples

-

If you have these environment variables:

+

If you have these variables defined in ~/.config/rofi/profile.conf

-
ROFI_BLEZZ_ARGS='-show blezz -modi blezz -auto-select -matching normal -blezz-config'
-ROFI_BLEZZ_THEMESTR='entry {placeholder:"Press hotkey";}'
-export ROFI_BLEZZ_ARGS ROFI_BLEZZ_THEMESTR
+
ROFI_BLEZZ_ARGS='-show blezz -modi blezz -auto-select -matching normal -blezz-directory'
+ROFI_BLEZZ_THEMESTR='entry {placeholder:"Press hotkey";}'

Then this:

-
rofile blezz ~/.config/blezz/content
+
rofile blezz Macro

is the same as this:

rofi -theme-str 'entry {placeholder:"Press hotkey";}' \
-     -show blezz -modi blezz -auto-select -matching normal -blezz-config \
-     ~/.config/blezz/content
+ -show blezz -modi blezz -auto-select -matching normal -blezz-directory \ + Macro
@@ -93,7 +94,7 @@

Distribution

diff --git a/doc/rofile.1.txt b/doc/rofile.1.txt index ceb4cc9..f27cddf 100644 --- a/doc/rofile.1.txt +++ b/doc/rofile.1.txt @@ -9,7 +9,7 @@ rofile(1) Name ---- -rofile - Use environment variables as rofi configuration. +rofile - Configurable rofi profiles. Synopsis -------- @@ -18,31 +18,32 @@ Synopsis Description ----------- -Runs rofi with arguments taken from 'profile's' environment variables. +Runs rofi with arguments determined by 'profile'. Any additional 'args' are also passed to rofi. -When invoked as 'rofile foo bar baz', rofile runs +Profile arguments are read from environment variables and from +~/.config/rofi/profile.conf . +When invoked as '$prog foo bar baz', rofile runs rofi -theme-str "$ROFI_FOO_THEMESTR" $ROFI_FOO_ARGS bar baz Examples -------- -If you have these environment variables: +If you have these variables defined in ~/.config/rofi/profile.conf - ROFI_BLEZZ_ARGS='-show blezz -modi blezz -auto-select -matching normal -blezz-config' + ROFI_BLEZZ_ARGS='-show blezz -modi blezz -auto-select -matching normal -blezz-directory' ROFI_BLEZZ_THEMESTR='entry {placeholder:"Press hotkey";}' - export ROFI_BLEZZ_ARGS ROFI_BLEZZ_THEMESTR Then this: - rofile blezz ~/.config/blezz/content + rofile blezz Macro is the same as this: rofi -theme-str 'entry {placeholder:"Press hotkey";}' \ - -show blezz -modi blezz -auto-select -matching normal -blezz-config \ - ~/.config/blezz/content + -show blezz -modi blezz -auto-select -matching normal -blezz-directory \ + Macro Authors -------