Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all blocklets to be configured via injected config properties (next branch) #132

Closed
41 tasks done
kb100 opened this issue Jan 8, 2018 · 3 comments
Closed
41 tasks done

Comments

@kb100
Copy link
Collaborator

kb100 commented Jan 8, 2018

In the upcoming release of i3blocks, arbitrary properties will be able to be injected into a blocklet's environment. The readability of the i3blocks configuration file will be substantially improved by making all block configuration done through these injected environmental variables.

By way of example, the volume-pulseaudio blocklet previously had an example config:

[volume-pulseaudio]
command=$SCRIPT_DIR/volume-pulseaudio -a
interval=once
signal=1

This should be replaced by something like

[volume-pulseaudio]
command=$SCRIPT_DIR/volume-pulseaudio
interval=once
signal=1
USE_ALSA_NAME=1

More generally, the README should include something like:

[volume-pulseaudio]
command=$SCRIPT_DIR/volume-pulseaudio
interval=once
signal=1
# exposed format variables: %s symbol, %v volume, %i index, %n name
#FORMAT_LONG=%s %v\% [%i:%n]
#FORMAT_SHORT=%s %v\% [%i]
#SUBSCRIBE=0
USE_ALSA_NAME=1
#USE_DEVICE_NAME=0
#AUDIO_HIGH_SYMBOL='  '
#AUDIO_MED_SYMBOL='  '
#AUDIO_LOW_SYMBOL='  '
#AUDIO_MUTED_SYMBOL='  '
#AUDIO_MED_THRESHOLD=50
#AUDIO_LOW_THRESHOLD=0
#COLOR_NON_MUTED=#ffffff
#COLOR_MUTED=#a0a0a0

For each blocklet, we must:

  1. Update the script itself to use environmental variables for all possible configuration. Command line argument code should not be deleted if possible in order to avoid breaking existing configurations.
  2. Update the README to include an example config which shows all configurable parameters. Parameters that are not used in the example config should still be included, but commented out with their default value.
  3. Update all example configs with the new syntax.

Note that while we are at it, now is a great time to implement format string options FORMAT_LONG and FORMAT_SHORT as above, or allowing different formats like FORMAT_UP and FORMAT_DOWN.
This can cut down on a lot of format specific configuration options. For instance, in the volume-pulseaudio block above, we could have FORMAT_HIGH, FORMAT_MED, FORMAT_LOW, FORMAT_MUTED and just let the user do exactly what they want.

All work done towards this end should be on the next branch, not the master branch.
If you want to help, submit pull requests against the next branch.

Here is a list of the status of all files in the repo and their conversion status:

  • afs
  • apt-upgrades
  • arch-update
  • bandwidth
  • bandwidth2
  • bandwidth3
  • battery
  • battery2
  • batterybar
  • calendar
  • cpu_usage
  • disk
  • disk-io
  • email
  • gpu-load
  • iface
  • kbdd_layout
  • keyindicator
  • key_layout
  • kubernetes
  • load_average
  • mediaplayer
  • memory
  • monitor_manager
  • openvpn
  • rofi-calendar
  • shutdown_menu
  • tahoe-lafs
  • temperature
  • time
  • usb
  • volume
  • volume-pulseaudio
  • wifi
  • wlan-dbm
  • ytdl-mpv
  • config.example
  • CONTRIBUTING.md
  • ISSUE_TEMPLATE.md
  • LICENSE.md
  • README.md

I will begin slowly working on this once the convention for how variables are injected is finalized. (Cf. vivien/i3blocks#279). Help is greatly welcomed.

kb100 added a commit that referenced this issue Jan 10, 2018
@kb100
Copy link
Collaborator Author

kb100 commented Jan 10, 2018

Helpful notes for converting:

For shell scripts that simply set default values at the beginning of the script, converting most options is as simple as changing, e.g.,

COLOR_BAD="#ff0000"

to

COLOR_BAD=${COLOR_BAD:-"#ff0000"}

kb100 added a commit that referenced this issue Jan 10, 2018
@kb100
Copy link
Collaborator Author

kb100 commented Jan 13, 2018

Note: for bash scripts, adding a format string can be done using the envsubst command. E.g. the user can specify in their config

FORMAT_UP='${iface}: up'

and the script will reference:

echo "$FORMAT_UP" | envsubst "${iface}"

The set -a option may be used for automatically exporting script variables to sub processes.

kb100 added a commit that referenced this issue Jan 13, 2018
kb100 added a commit that referenced this issue Jan 13, 2018
kb100 added a commit that referenced this issue Jan 13, 2018
kb100 added a commit that referenced this issue Jan 13, 2018
kb100 added a commit that referenced this issue Jan 13, 2018
kb100 added a commit that referenced this issue Jan 13, 2018
kb100 added a commit that referenced this issue Jan 14, 2018
kb100 added a commit that referenced this issue Jan 15, 2018
kb100 added a commit that referenced this issue Jan 15, 2018
kb100 added a commit that referenced this issue Jan 15, 2018
kb100 added a commit that referenced this issue Jan 15, 2018
kb100 added a commit that referenced this issue Jan 17, 2018
kb100 added a commit that referenced this issue Jan 17, 2018
kb100 added a commit that referenced this issue Jan 17, 2018
kb100 added a commit that referenced this issue Jan 17, 2018
kb100 added a commit that referenced this issue Jun 1, 2018
kb100 added a commit that referenced this issue Jun 1, 2018
kb100 added a commit that referenced this issue Jun 1, 2018
kb100 added a commit that referenced this issue Jun 1, 2018
kb100 added a commit that referenced this issue Jun 1, 2018
kb100 added a commit that referenced this issue Jun 1, 2018
kb100 added a commit that referenced this issue Jun 1, 2018
RIT80 pushed a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 pushed a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 pushed a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 pushed a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 pushed a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
RIT80 added a commit to RIT80/i3blocks-contrib that referenced this issue Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant