Skip to content

Instantly share code, notes, and snippets.

@sakhmatd
Created May 24, 2021 09:59
Show Gist options
  • Save sakhmatd/eeb709746b50f0ff822558473dff1eda to your computer and use it in GitHub Desktop.
Save sakhmatd/eeb709746b50f0ff822558473dff1eda to your computer and use it in GitHub Desktop.
Use brightnessctl and dunst to create a brightness indicator for DE-less setups
#!/bin/bash
# dunstBright
msgId="3378455"
brightnessctl "$@" > /dev/null
brightnow="$(brightnessctl g)"
brightmax="$(brightnessctl m)"
brightpercent=$(awk "BEGIN {print ${brightnow}/${brightmax}*100}")
dunstify -a "changeBrightness" -u low -r "$msgId" \
-h int:value:"$brightpercent" "Brightness: ${brightpercent}%"
@dpi0
Copy link

dpi0 commented Apr 5, 2025

here's something with colors and fixed decimal issue

#!/usr/bin/env bash

brightnessctl "$@" > /dev/null

msgID=31232
color="#FFBF00FF"
brightnow="$(brightnessctl g)"
brightmax="$(brightnessctl m)"
brightness=$(awk "BEGIN {printf \"%d\", ${brightnow}/${brightmax}*100}")

dunstify -a "changeBrightness" \
  "󰃞 Brightness: ${brightness}%" \
  -u low \
  -t 700 \
  -r "$msgID" \
  -h int:value:"$brightness" \
  -h string:fgcolor:"$color" \
  -h string:frcolor:"$color" \
  -h string:hlcolor:"$color"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment