Skip to content

Instantly share code, notes, and snippets.

@aRmanNM
Last active December 12, 2025 13:16
Show Gist options
  • Select an option

  • Save aRmanNM/7edb3cf0b80c182daf804f71aa3af567 to your computer and use it in GitHub Desktop.

Select an option

Save aRmanNM/7edb3cf0b80c182daf804f71aa3af567 to your computer and use it in GitHub Desktop.
add custom block to i3 status bar (minimal with simple wrapper script)

copy i3status.conf file to your .config path (~/.config/i3status/config)

mkdir ~/.config/i3status
cp /etc/i3status.conf ~/.config/i3status/config

update config file to allow json output (also add your desired changes here):

general {
	output_format = i3bar // add this line
    colors = true
    interval = 5
}

next create your wrapper script with following content (i put it on ~/.config/i3status/wrapper.sh):

#!/bin/bash

i3status | while read -r line; do
    # Step 1: Forward header line
    if [[ "$line" =~ ^\{ ]]; then
        echo "$line"
        continue
    fi

    # Step 2: Forward array start line
    if [[ "$line" == "[" ]]; then
        echo "$line"
        continue
    fi

    jalali_date=$(jdate +'%Y-%m-%d') # make sure to install required commands if required. for this to work u have to install 'jcal' package

    # Build a JSON object for your custom block
    custom_block="{\"full_text\":\"$jalali_date\",\"color\":\"#ffffff\"}"

    # Insert your block before the rest
    echo "${line%]}, $custom_block]"
done

next tell i3 to use your wrapper script (edit ~/.config/i3/config file):

bar {
    status_command ~/.config/i3status/wrapper.sh
}

now restart i3 ... DONE!

if u want indicator on the left use this script:

#!/bin/bash

i3status | while read -r line; do
    # Step 1: Forward header line
    if [[ "$line" =~ ^\{ ]]; then
        echo "$line"
        continue
    fi

    # Step 2: Forward array start line
    if [[ "$line" == "[" ]]; then
        echo "$line"
        continue
    fi

    # Step 3: Process status entries
    # Remove leading comma if present
    if [[ "$line" =~ ^, ]]; then
      prefix=","
      line="${line#,}"
    else
       prefix=""
    fi

    jalali_date=$(jdate +'%Y-%m-%d')

    # Build a JSON object for your custom block
    custom_block="{\"full_text\":\"$jalali_date\",\"color\":\"#ffffff\"}"

    # Insert your block before the rest
    echo "${prefix}[$custom_block, ${line#\[}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment