The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

Shared config for multiple dmenu scripts

asked 2012-12-19 00:30:27 +0000

joepd gravatar image

With the release of i3-dmenu-desktop, my collection of daily used dmenu-scripts has grown again. And I like to have 'em vertical, with a limited number of lines, case-insensitive, and with some particular colors (and have the patches installed when needed). But what I am looking for, is to control these settings from one place.

Have I missed a patch that listens to environment variables? Or is there a way around those?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-01-05 21:27:23 +0000

Since i3 uses sh to execute commands, you can use command substitution within commands as a workaround. I have tested it with the following within the i3's configuration file:

  1. set $font -misc-fixed-medium-r-normal-*-15-140-75-75-c-90-iso10646-1
  2. set $dmc $(</tmp/dmenu.conf)
  3. exec --no-startup-id echo '-b -fn $font' > /tmp/dmenu.conf
  4. bindsym $Mod1+x exec /usr/bin/dmenu_run $dmc
  5. bindsym $Mod1+m exec --no-startup-id i3-dmenu-desktop --dmenu="/usr/bin/dmenu -i $dmc"

Let me explain the above:

  1. Set a variable for a font. I do it to illustrate, that variables can be used in dmenu parameter string.
  2. Set a variable (or call it a macro) for inserting dmenu parameter string stored in /tmp/dmenu.conf. If you want to use ENVARIABLE environment variable instead, edit this line to something like set $dmc $(echo $ENVARIABLE) and omit the following line.
  3. Save desired dmenu parameter string to a file. Note that previously set variables can be used. Omit this line if you already have the dmenu parameter string saved somewhere (you'll have to modify the previous line). When omitting this line, you can't use variables inside the dmenu parameter string any more.
  4. Simple example of using the configuration variable.
  5. More complex example. You can add more parameters (-i was added here), as well as use the config as a parameter of another command (just remember to use quotation marks ‹"› – using apostrophes ‹'› would result in executing i3-dmenu-desktop --dmenu='/usr/bin/dmenu -i $(</tmp/dmenu.conf)' by the shell and $(</tmp/dmenu.conf) is not a valid dmenu parameter)
edit flag offensive delete link more

Comments

Excellent! And as a bonus, some nifty usage of sh. Thanks for sharing your tricks :)

joepd gravatar imagejoepd ( 2013-01-08 22:34:21 +0000 )edit

Question Tools

Stats

Asked: 2012-12-19 00:30:27 +0000

Seen: 1,197 times

Last updated: Jan 05 '13