Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Desktop Environments
  • Search

Using Environment Variables in Openbox Keybindings

Problems with GUI applications? Questions about X, KDE, Gnome, Fluxbox, etc.? Come on in. NOTE: For multimedia, go up one forum
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
Xander314
n00b
n00b
Posts: 61
Joined: Mon Apr 16, 2012 10:13 am

Using Environment Variables in Openbox Keybindings

  • Quote

Post by Xander314 » Sat Mar 01, 2014 1:43 pm

I am setting up keybindings for openbox, several of which will run Chrome (browser as well as mail, calendar etc as webapps). But down the line I might want to change my browser, so I tried setting a BROWSER environment variable and then putting this in rc.xml:

Code: Select all

<keybind ...>
  <action name="Execute">
    <command>$BROWSER</command>
  </action>
</keybind>
But Openbox complains at this, saying that it can't execute the command "$BROWSER". I have checked that the variable is non empty, so it seems the problem is that OpenBox doesn't accept environment variables in keybind commands. Is there some way I can make Openbox interpret the environment variable correctly?

EDIT: I'm using the following workaround, but surely there's a better way...

Code: Select all

<keybind ...>
  <action name="Execute">
    <command>~/bin/env-launch.sh "BROWSER"</command>
  </action>
</keybind>
env-launch.sh:

Code: Select all

eval command=\$$1
$command
Top
BitJam
Advocate
Advocate
Posts: 2513
Joined: Tue Aug 12, 2003 4:15 pm
Location: Silver City, NM

  • Quote

Post by BitJam » Sat Mar 08, 2014 1:47 am

This post suggests you set the environment variables in ~/.config/openbox/environment. I don't know if this will work for you and if it does work I don't know if it will solve your problem.
Top
braydenjw
n00b
n00b
Posts: 1
Joined: Tue Oct 03, 2017 1:39 am

  • Quote

Post by braydenjw » Tue Oct 03, 2017 1:47 am

Sorry to resurrect and old post, but this was the first result on Google when searching for this problem.

It's true that environment variables won't work in Openbox's XML configuration files (like rc.xml and menu.xml). You can invoke scripts and use environment variables inside those scripts, but it's unfortunate that you must get a third file involved.

A pseudo-work-around is to use aliases instead of environment variables. As an example, in Openbox's environment file (~/.config/openbox/environment), I defined this alias:

Code: Select all

alias volumectl="pactl set-sink-volume $(pactl list short | grep RUNNING | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,')"
...and now from within rc.xml I can use the commands "volumectl +1%" and "volumectl -1%" to change the volume on the active sink.

So if you can re-think your problem in a way that can use aliases instead of environment variables, you can achieve the same behaviour.

For this particular user, they could define "alias browser=firefox" in the environment file (or whichever browser they wish to run) and just use the "browser" command in rc.xml.
Top
Juippisi
Developer
Developer
User avatar
Posts: 783
Joined: Fri Sep 30, 2005 3:51 pm
Location: /home

  • Quote

Post by Juippisi » Tue Oct 03, 2017 5:21 am

^ Thats pretty much how I dealt with it as well. Made few .sh files in my ~/bin directory and called those from rc.conf.

But changing your default browser in rc.conf is just one line of sed anyway...

Something like

Code: Select all

sed -i 's/chromium/firefox/g' rc.conf
Top
Post Reply

4 posts • Page 1 of 1

Return to “Desktop Environments”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic