2

I am using dmenu list selection tool on linux. Let's assume my typical invocation goes like that:

ls | dmenu $DMENU_OPTIONS 

Settings from .dmenurc:

DMENU_FN="Liberation:size=16"
DMENU_OPTIONS="<...> -fn $DMENU_FN"

Then, I have use some quicklaunch script based on dmenu. It takes dmenu options with this line:

dmenu_cmd="dmenu $DMENU_OPTIONS"

Now, I switch font name to Liberation Mono and the font piece is now recognised as two parameters for one option. Dmenu gets syntax error. I couldn't get around that using quotes or backslashes. So there is a variable with a spacebar which should be passed to another variable.

  • 1
    Depending on how many dereferences there are, you might need a lot of consecutive backslashes. How many did you try? Did you put quotes around the top level pass of `ls | dmenu "$DMENU_OPTIONS" | wc`? – Paul Hodges Oct 09 '17 at 20:26
  • If I put backslash before that whitespace it doesn't do any job, i.e. the two chars are passed as is. How I check it: edit rc file => $ . .dmenurc && ls | dmenu $DMENU_OPTIONS => get error => $ echo $DMENU_OPTIONS => see chars remain as-is – Possum Gallo Oct 09 '17 at 20:34
  • Quotes on "$DMENU_OPTIONS" don't help. I hope some stuff with brackets or a function would do the trick.. – Possum Gallo Oct 09 '17 at 20:46
  • Whatever backslashes/quotes I put the `$DMENU_OPTIONS` and check with `echo` , `dmenu "$DMENU_OPTIONS"` fails to eat that whitespace while same inline `dmenu -fn "Liberation Mono"` and `dmenu -fn Liberation\ Mono` works. – Possum Gallo Sep 04 '18 at 08:21

2 Answers2

2

if you split font name from other arguments like the example below and use double quotes, it will work:

DMENU_FONT="Dejavu Sans Mono:medium:size=18"
DMENU_OPTS="-nb #191919 -nf #FF0000 -sb #FF9318 -sf #191919"
ls | dmenu -fn "$DMENU_FONT" $DMENU_OPTS

Notice that DMENU_FONT is within double quotes while DMENU_OPTS is not, as the goal is returning font name as a single value, and the second variable as multiple arguments.

Hope it helps.

silveiralexf
  • 374
  • 5
  • 18
0

A workaround I used for this is to create LiberMono alias for Liberation Mono font using fontconfig. Just add such file:

~/.config/fontconfig/fonts.conf

<!-- Insert joke here -->
<match>
  <test name="family"><string>LiberMono</string></test>
  <edit name="family" mode="assign" binding="strong">
    <string>Liberation Mono</string>
  </edit>
</match>