Skip to content

Commit

Permalink
Add config to rofile
Browse files Browse the repository at this point in the history
  • Loading branch information
DMBuce committed May 24, 2022
1 parent 3ee1265 commit da3aab3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 35 deletions.
14 changes: 10 additions & 4 deletions bin/rofile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

# check args
prog="${0##*/}"
usage="Usage: ${0##*/} PROFILE [ARGS]
usage="Usage: ${0##*/} <profile> [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 <profile>. Any additional <args>
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
"
Expand All @@ -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_]/_}"
Expand Down
23 changes: 12 additions & 11 deletions doc/rofile.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <profile> [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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
23 changes: 12 additions & 11 deletions doc/rofile.1.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>rofile(1)</h1>
<div class="sect1">
<h2 id="_name">Name</h2>
<div class="sectionbody">
<div class="paragraph"><p>rofile - Use environment variables as rofi configuration.</p></div>
<div class="paragraph"><p>rofile - Configurable rofi profiles.</p></div>
</div>
</div>
<div class="sect1">
Expand All @@ -41,9 +41,11 @@ <h2 id="_synopsis">Synopsis</h2>
<div class="sect1">
<h2 id="_description">Description</h2>
<div class="sectionbody">
<div class="paragraph"><p>Runs rofi with arguments taken from <em>profile&#8217;s</em> environment variables.
<div class="paragraph"><p>Runs rofi with arguments determined by <em>profile</em>.
Any additional <em>args</em> are also passed to rofi.</p></div>
<div class="paragraph"><p>When invoked as <em>rofile foo bar baz</em>, rofile runs</p></div>
<div class="paragraph"><p>Profile arguments are read from environment variables and from
~/.config/rofi/profile.conf .
When invoked as <em>$prog foo bar baz</em>, rofile runs</p></div>
<div class="literalblock">
<div class="content">
<pre><code>rofi -theme-str "$ROFI_FOO_THEMESTR" $ROFI_FOO_ARGS bar baz</code></pre>
Expand All @@ -53,24 +55,23 @@ <h2 id="_description">Description</h2>
<div class="sect1">
<h2 id="_examples">Examples</h2>
<div class="sectionbody">
<div class="paragraph"><p>If you have these environment variables:</p></div>
<div class="paragraph"><p>If you have these variables defined in ~/.config/rofi/profile.conf</p></div>
<div class="literalblock">
<div class="content">
<pre><code>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</code></pre>
<pre><code>ROFI_BLEZZ_ARGS='-show blezz -modi blezz -auto-select -matching normal -blezz-directory'
ROFI_BLEZZ_THEMESTR='entry {placeholder:"Press hotkey";}'</code></pre>
</div></div>
<div class="paragraph"><p>Then this:</p></div>
<div class="literalblock">
<div class="content">
<pre><code>rofile blezz ~/.config/blezz/content</code></pre>
<pre><code>rofile blezz Macro</code></pre>
</div></div>
<div class="paragraph"><p>is the same as this:</p></div>
<div class="literalblock">
<div class="content">
<pre><code>rofi -theme-str 'entry {placeholder:"Press hotkey";}' \
-show blezz -modi blezz -auto-select -matching normal -blezz-config \
~/.config/blezz/content</code></pre>
-show blezz -modi blezz -auto-select -matching normal -blezz-directory \
Macro</code></pre>
</div></div>
</div>
</div>
Expand All @@ -93,7 +94,7 @@ <h2 id="_distribution">Distribution</h2>
<div id="footer">
<div id="footer-text">
Last updated
2022-05-22 13:42:19 CDT
2022-05-23 19:18:09 CDT
</div>
</div>
</body>
Expand Down
19 changes: 10 additions & 9 deletions doc/rofile.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rofile(1)
Name
----

rofile - Use environment variables as rofi configuration.
rofile - Configurable rofi profiles.

Synopsis
--------
Expand All @@ -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
-------
Expand Down

0 comments on commit da3aab3

Please sign in to comment.