Skip to content

Openbox HUD Wiki

Piotr Miller edited this page Aug 25, 2019 · 43 revisions

About

This script is intended to simplify assigning laptop-specific keys and events to actions and display graphical messages in Openbox window manager. This way one can, for instance, change volume level or screen brightness and see a graphical confirmation by just binding a key to a single command. Furthermore - assigning a command in Tint2 preferences allows to see alerts concerning the AC and battery state, and also suspend on critical battery level.

In the 0.1.8 version the Timer / Stopwatch feature was added. If you've just upgraded from a prior version, please run obhud --autoconfig tint2 to add the Tint2 executor.

preview

Autoconfig

You can either type obhud in terminal, and use the menu described in README, or enter commands as below.

1:

If you've just installed Obhud, or upgraded from below 0.1.4, you can make use of --autoconfig options. Type in terminal:

obhud --autoconfig all

Adds all the necessary keybindings in ~/home/config/openbox/rc.xml and configures Tint2 AC- and battery-related commands in ~/home/config/tint2/tint2rc. Use if you have Tint2 installed.

2:

obhud --autoconfig keys

Only adds keybindings in ~/home/config/openbox/rc.xml.

3:

obhud --autoconfig tint2

Only adds event-related commands and the Timer/Stopwatch executor in ~/home/config/tint2/tint2rc. Edit or remove if necessary in Tint2 settings.

Commands

Read below if you'd like to configure commands on your own.

obhud --volume {up} | {down} | {toggle}
obhud --brightness {up} | {down}
obhud --battery {low} | {LOW} | {full}
obhud --ac {connected} | {disconnected}
obhud --touchpad {on} | {off} | {toggle}
obhud --autoconfig {keys} | {tint2} | {all}
obhud --screens {switch} | {switchv} | {single} | {clone} | {right} | {left} | {above} | {below} | {detect}

You can either assign commands to keys with obkey...

obkey

...or just add the XML below to the <keyboard></keyboard> section of your rc.xml file:

    <keybind key="XF86MonBrightnessDown">
      <action name="Execute">
        <command>obhud --brightness down</command>
      </action>
    </keybind>
    <keybind key="XF86MonBrightnessUp">
      <action name="Execute">
        <command>obhud --brightness up</command>
      </action>
    </keybind>
    <keybind key="XF86AudioRaiseVolume">
      <action name="Execute">
        <command>obhud --volume up</command>
      </action>
    </keybind>
    <keybind key="XF86AudioLowerVolume">
      <action name="Execute">
        <command>obhud --volume down</command>
      </action>
    </keybind>
    <keybind key="XF86AudioMute">
      <action name="Execute">
        <command>obhud --volume toggle</command>
      </action>
    </keybind>
    <keybind key="XF86TouchpadToggle">
      <action name="Execute">
        <command>obhud --touchpad toggle</command>
      </action>
    </keybind>
    <keybind key="XF86TouchpadOn">
      <action name="Execute">
        <command>obhud --touchpad on</command>
      </action>
    </keybind>
    <keybind key="XF86TouchpadOff">
      <action name="Execute">
        <command>obhud --touchpad off</command>
      </action>
    </keybind>
    <keybind key="W-P">
      <action name="Execute">
        <command>obhud --screens switch</command>
      </action>
    </keybind>
    <keybind key="S-W-P">
      <action name="Execute">
        <command>obhud --screens switchv</command>
      </action>
    </keybind>

To make use of the battery-related commands, enter them in the Tint2 preferences:

tint2

Timer / Stopwatch

This feature uses the Tint2 executor to display time. Click the executor:

Timer not set

This will display a simple dialog window:

Timer dialog

Click Stopwatch to start the stopwatch:

Stopwatch

or enter time and click Start timer:

Timer

Click Clear&Close to abort current timer / stopwatch.

When the Timer stops counting down, you'll hear the alarm sound and see the notification:

Timer

Timer / stopwatch setup

Running the obhud --autoconfig tint2 command will add the following at the very end of your ~/config/tint2/tint2rc file:

#-------------------------------------
# Executor 99
execp = new
execp_command = ~/.config/obhud/timer.sh
execp_interval = 1
execp_has_icon = 0
execp_cache_icon = 0
execp_continuous = 0
execp_markup = 0
execp_tooltip = 
execp_lclick_command = obhud --timer gui
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = Cantarell 9
execp_font_color = #ffffff 100
execp_padding = 0 0
execp_background_id = 5
execp_centered = 1
execp_icon_w = 0
execp_icon_h = 0

After opening Tint2 configuration the executor should be renumbered automatically and moved to a proper place. Feel free to adjust its look to your needs. Note: the obhud --autoconfig tint2 does not remove the executor. If found, it will not be added/modified. To reset it to defaults, you'll have to remove it from the ~/config/tint2/tint2rc manually!

Commands description

obhud --volume up

Increases volume with the amixer set Master 10%+ unmute command, displays graphical notification:

volume

obhud --volume down

Decreases volume with the amixer set Master 10%- command, displays graphical notification.

obhud --volume toggle

Turns sound on/off with the amixer set Master toggle command, displays graphical notification.

volume-toggle

obhud --brightness up

Increases brightness with the xbacklight +10 command, displays graphical notification:

brightness

obhud --brightness down

Decreases brightness with the xbacklight -10 command, displays graphical notification.

obhud --battery low

Displays graphical notification (10 seconds long), then suspends the system with systemctl suspend.

obhud --battery LOW

Plays sound warning (2 seconds), displays graphical notification (10 seconds), then suspends the system with systemctl suspend.

battery-low

obhud --battery full

Displays graphical notification.

obhud --ac connected

Displays graphical notification:

ac-connected

obhud --ac disconnected

Displays graphical notification.

obhud --touchpad toggle

NOTE: If it comes to the touchpad button, it may behave differently on different machines: either always return the XF86TouchpadToggle value, or XF86TouchpadOn and XF86TouchpadOff every second press. Check which way it works on your laptop with the xev command (xorg-xev package).

The obhud --touchpad toggle command first checks the touchpad status, then turns it on / off accordingly, and displays graphical notification:

touchpad-on

obhud --touchpad on

Turns the touchpad on with the synclient TouchpadOff=0 command, displays graphical notification.

obhud --touchpad off

Turns the touchpad off with the synclient TouchpadOff=1 command, displays graphical notification.

obhud --screens switch

Switches primary / secondary display setup horizontally in order single -> clone -> secondary right -> secondary left; displays graphical notification. Assigned to Displays key / Super-P by default:

volume

obhud --screens switchv

Switches primary / secondary display setup vertically in order single -> clone -> secondary above -> secondary below; displays graphical notification. Assigned to Shift-Displays key / Shift-Super-P by default.

obhud --screens single

Selects primary display only, turns secondary off, displays graphical notification.

obhud --screens clone

Clones primary display to secondary, displays graphical notification. Selects single if secondary not attached.

obhud --screens right

Sets the secondary display to the right of the primary one, displays graphical notification. Selects single if secondary not attached.

obhud --screens left

Sets the secondary display to the left of the primary one, displays graphical notification. Selects single if secondary not attached.

obhud --screens above

Sets the secondary display above the primary one, displays graphical notification. Selects single if secondary not attached.

obhud --screens below

Sets the secondary display below the primary one, displays graphical notification. Selects single if secondary not attached.

obhud --screens detect

Detects attached displays. Usually no need to use from the command line.

Note: it makes sense to add a command like obhud --screens right (change to match your preferred setup) to your autoconfig file. In case the secondary display is currently detached, the single setup will be chosen automatically.

Installation

I only packaged this script for Arch Linux. Please search the obhud package in AUR.

Feel free to make packages for other Linux distributions. Just let me know for them to be linked here.

Optional dependencies

The light package may be of use if brightness keys don't work for you. If found, light will be used instead of xbacklight to increase/decrease the brightness level. Should work with Radeon graphics, which does not work with xbacklight.

Configuration

If you'd like to change default bash comands (e.g. to increase/decrease volume/brightness by 5% instead of 10%), you can edit the ~/.config/obhud/obhud.conf file. Leave double %% as is.

[Commands]
# You can modify default commands in the ~/config/obhud/obhud.conf file.
# In case you got lost, just delete it. It'll be re-created from
# default /etc/obhud/obhud.conf file.
volume_up = amixer set Master 10%%+ unmute -q
volume_down = amixer set Master 10%%- -q
volume_toggle = amixer set Master toggle -q
brightness_up = xbacklight +10
brightness_down = xbacklight -10
light_increase = light -A 10
light_decrease = light -U 10
touchpad_on = synclient TouchpadOff=0
touchpad_off = synclient TouchpadOff=1

light_increase and light_decrease commands are used with the light-git package installed. In such case brightness_up and brightness_down commands will be ignored.

Troubleshooting

For the xbacklight command to work, you may need the /etc/X11/xorg.conf.d/10-backlight.conf file:

Section "Device"
    Identifier  "Card0"
    Driver      "intel"
    Option      "Backlight"  "intel_backlight"
EndSection

If it doesn't work, just install the light-git package mentioned above.