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

bindsym not working -- command works fine in terminal

asked 2015-05-29 13:58:47 +0000

nk gravatar image

I have set this keybind in order to switch layouts with $mod+space(duh!). However, while the command works fine when run in rxvt with bash, it doesnt seem to work with the keybind. $SHELL is /bin/bash and I have disabled the other $mod+space keybind so overlapping keybinds is not the problem.

bindsym  $mod+space exec "setxkbmap -layout $([[ $(setxkbmap -query | awk '/layout/{ print $2 }') == us ]] && echo 'gr' || echo 'us')"

Running version 4.8 on Jessie.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-05-29 14:25:55 +0000

Airblader gravatar image

I'm assuming the dollar signs are a problem since they will be interpreted as a variable.

For scripts like this I'd usually just suggest to move it into a dedicated script and then simply execute that script from your config.

edit flag offensive delete link more

Comments

Ah that was the problem, thanks :)

nk gravatar imagenk ( 2015-05-29 14:34:43 +0000 )edit

Why does i3 do this? If I don't use syntax, I can get around i3's internal layer of quoting usually with ``` exec bash -c "[comands here]" ``` but if my commands include [, $, or some other set of things I haven't worked out it gives an error, points at them, and doesn't explain why.

kousu gravatar imagekousu ( 2015-05-31 20:02:29 +0000 )edit

I think you can escape a dollar sign by doing `$$`. Dollar signs are special because they denote variables in the config. As the docs state,there is no plans of changing this. It makes sense to put complicated commands into separate, dedicated scripts anyway. Maintaining quoted versions is horrible.

Airblader gravatar imageAirblader ( 2015-05-31 20:45:38 +0000 )edit

I've been doing that, but it bugs me that my config is getting scattered across shell scripts. But if that's the i3 way I can adapt :)

kousu gravatar imagekousu ( 2015-06-01 05:20:48 +0000 )edit

It's not really "the i3 way", but being a software developer, I actually think it's a whole lot cleaner to not put tons of shell scripts into a plain text configuration file. Just keep them in a specific directory and they're neatly organized. :)

Airblader gravatar imageAirblader ( 2015-06-01 06:47:56 +0000 )edit

Question Tools

1 follower

Stats

Asked: 2015-05-29 13:58:47 +0000

Seen: 198 times

Last updated: May 29