I3status -- colorizing battery status strings

Hi folks,

Newcomer to Garuda as well as i3 as a window manager. Impressed with both. Did have a question though: In playing with the i3status components I was trying to get the battery status to display, with many failed attempts. After trying a bunch of things, I tried removing the <span> decorations from status_full, status_chr, etc. and it finally worked. These decorations were AFAIK part of the vanilla install I performed. Here's an example of what was in my .config/i3status/config file:

format = "<span color='#FEFF72'> %status: %percentage </span>" 
status_chr = "<span color='#00e64d'>[  ]  </span> "

Apparently the span decoration on status_chr cause i3status to have fits. If I remove those tags and just use the UTF8 content it works as expected. It was not clear to me from the i3status documentation whether or not decorating the status strings is allowed. The stock i3status config file from install also includes colors=yes and markup=pango.

My garuda-inxi:
System:
  Kernel: 5.18.5-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 12.1.0
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=4a3429c4-163c-46f1-b956-cb2c002214da rw rootflags=subvol=@
    quiet quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0
    loglevel=3
  Desktop: i3 v: 4.20.1 info: i3bar vt: 7 dm: LightDM v: 1.30.0
    Distro: Garuda Linux base: Arch Linux
Machine:
  Type: Portable System: Dell product: Inspiron 5423 v: N/A
    serial: <superuser required> Chassis: type: 8 serial: <superuser required>
  Mobo: Dell model: 0F45CW v: A06 serial: <superuser required> UEFI: Dell
    v: A06 date: 09/17/2012
Battery:
  ID-1: BAT0 charge: 33.4 Wh (89.3%) condition: 37.4/44.4 Wh (84.3%)
    volts: 12.0 min: 11.1 model: SMP-SDI2.0 DELL 8JVDG27 type: Li-ion
    serial: <filter> status: discharging
CPU:
  Info: model: Intel Core i5-3317U bits: 64 type: MT MCP arch: Ivy Bridge
    gen: core 3 built: 2012-15 process: Intel 22nm family: 6
    model-id: 0x3A (58) stepping: 9 microcode: 0x21
  Topology: cpus: 1x cores: 2 tpc: 2 threads: 4 smt: enabled cache:
    L1: 128 KiB desc: d-2x32 KiB; i-2x32 KiB L2: 512 KiB desc: 2x256 KiB
    L3: 3 MiB desc: 1x3 MiB
  Speed (MHz): avg: 1237 high: 1759 min/max: 800/2600 scaling:
    driver: intel_cpufreq governor: schedutil cores: 1: 1759 2: 1118 3: 1230
    4: 841 bogomips: 13568
  Flags: avx ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf
    mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: mmio_stale_data status: Not affected
  Type: spec_store_bypass
    mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1
    mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW,
    STIBP: conditional, RSB filling
  Type: srbds status: Vulnerable: No microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel 3rd Gen Core processor Graphics vendor: Dell driver: i915
    v: kernel arch: Gen7 process: Intel 22nm built: 2012-13 ports:
    active: LVDS-1 empty: DP-1,HDMI-A-1,VGA-1 bus-ID: 00:02.0
    chip-ID: 8086:0166 class-ID: 0300
  Device-2: Microdia Laptop_Integrated_Webcam_HD type: USB driver: uvcvideo
    bus-ID: 1-1.5:5 chip-ID: 0c45:6448 class-ID: 0e02
  Display: x11 server: X.Org v: 21.1.3 compositor: Picom v: git-7e568
    driver: X: loaded: modesetting alternate: fbdev,intel,vesa gpu: i915
    display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1366x768 s-dpi: 96 s-size: 361x203mm (14.21x7.99")
    s-diag: 414mm (16.31")
  Monitor-1: LVDS-1 model: AU Optronics 0x233c built: 2012 res: 1366x768
    hz: 60 dpi: 112 gamma: 1.2 size: 309x173mm (12.17x6.81")
    diag: 354mm (13.9") ratio: 16:9 modes: 1366x768
  Message: Unable to show GL data. Required tool glxinfo missing.
Audio:
  Device-1: Intel 7 Series/C216 Family High Definition Audio vendor: Dell
    driver: snd_hda_intel v: kernel bus-ID: 00:1b.0 chip-ID: 8086:1e20
    class-ID: 0403
  Sound Server-1: ALSA v: k5.18.5-zen1-1-zen running: yes
  Sound Server-2: PulseAudio v: 16.1 running: no
  Sound Server-3: PipeWire v: 0.3.52 running: yes
Network:
  Device-1: Intel Centrino Wireless-N 2230 driver: iwlwifi v: kernel pcie:
    gen: 1 speed: 2.5 GT/s lanes: 1 bus-ID: 07:00.0 chip-ID: 8086:0887
    class-ID: 0280
  IF: wlp7s0 state: up mac: <filter>
  Device-2: Qualcomm Atheros AR8162 Fast Ethernet vendor: Dell driver: alx
    v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: e000 bus-ID: 09:00.0
    chip-ID: 1969:1090 class-ID: 0200
  IF: enp9s0 state: down mac: <filter>
Bluetooth:
  Device-1: Intel Centrino Bluetooth Wireless Transceiver type: USB
    driver: btusb v: 0.8 bus-ID: 1-1.4:4 chip-ID: 8087:07da class-ID: e001
  Report: bt-adapter ID: hci0 rfk-id: 1 state: down
    bt-service: enabled,running rfk-block: hardware: no software: yes
    address: <filter>
Drives:
  Local Storage: total: 495.58 GiB used: 12.45 GiB (2.5%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/sda maj-min: 8:0 vendor: Seagate model: ST500LT012-9WS142
    size: 465.76 GiB block-size: physical: 4096 B logical: 512 B
    speed: 3.0 Gb/s type: HDD rpm: 5400 serial: <filter> rev: SDM1
    scheme: GPT
  ID-2: /dev/sdb maj-min: 8:16 vendor: Samsung model: SSD PM830 mSATA 32GB
    size: 29.82 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    type: SSD serial: <filter> rev: 3D1Q scheme: GPT
Partition:
  ID-1: / raw-size: 204.89 GiB size: 204.89 GiB (100.00%)
    used: 12.4 GiB (6.1%) fs: btrfs dev: /dev/sda9 maj-min: 8:9
  ID-2: /boot/efi raw-size: 500 MiB size: 496 MiB (99.20%)
    used: 55.3 MiB (11.2%) fs: vfat dev: /dev/sda1 maj-min: 8:1
  ID-3: /home raw-size: 204.89 GiB size: 204.89 GiB (100.00%)
    used: 12.4 GiB (6.1%) fs: btrfs dev: /dev/sda9 maj-min: 8:9
  ID-4: /var/log raw-size: 204.89 GiB size: 204.89 GiB (100.00%)
    used: 12.4 GiB (6.1%) fs: btrfs dev: /dev/sda9 maj-min: 8:9
  ID-5: /var/tmp raw-size: 204.89 GiB size: 204.89 GiB (100.00%)
    used: 12.4 GiB (6.1%) fs: btrfs dev: /dev/sda9 maj-min: 8:9
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: zram size: 5.66 GiB used: 239.5 MiB (4.1%)
    priority: 100 dev: /dev/zram0
  ID-2: swap-2 type: partition size: 11.12 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/sda10 maj-min: 8:10
Sensors:
  System Temperatures: cpu: 46.0 C mobo: 44.0 C
  Fan Speeds (RPM): cpu: 2978
Info:
  Processes: 263 Uptime: 3h 49m wakeups: 1 Memory: 5.66 GiB
  used: 3.34 GiB (59.1%) Init: systemd v: 251 default: graphical
  tool: systemctl Compilers: gcc: 12.1.0 Packages: pacman: 1409 lib: 365
  Shell: Bash v: 5.1.16 running-in: alacritty inxi: 3.3.18
Garuda (2.6.4-1):
  System install date:     2022-06-20
  Last full system update: 2022-06-23 ↻
  Is partially upgraded:   No
  Relevant software:       NetworkManager
  Windows dual boot:       Probably (Run as root to verify)
  Snapshots:               Snapper
  Failed units:

Welcome :slight_smile:
I think, but not sure, we can only use one color set by format.

order += "battery 0"

battery 0 {
format = "<span color='#008bef'> %status %percentage %remaining %emptytime</span>"
path = "/sys/class/power_supply/BAT0/uevent"
format_down = "No battery"
low_threshold = 10
status_chr = " 🠩"
status_bat = "  🠫"
#status_unk = "[? ukwn ] "
status_full = " "
last_full_capacity = true
hide_seconds = true
integer_battery_capacity = true
}

image

image

2 Likes