Skip to content

Instantly share code, notes, and snippets.

@DaveWishesHe
Created August 3, 2021 11:26
Show Gist options
  • Save DaveWishesHe/e9d9ef6d50f61143a4e57170b4bd3456 to your computer and use it in GitHub Desktop.
Save DaveWishesHe/e9d9ef6d50f61143a4e57170b4bd3456 to your computer and use it in GitHub Desktop.
Dirty script to randomly change my new keyboard's backlight color.
#!/bin/bash
# Randomly change the keyboard backlight color. Add to root's crontab like
#
# */15 * * * * bash /home/dave/scripts/color_changer.sh
#
# to change the backlight colour randomly every 15 minutes.
RANDOM=$$$(date +%s)
colors=("0x0000FF" "0xFF0000" "0x00FF00" "0xFFFF00" "0x00FFFF" "0xFF00FF")
random_color=${colors[$RANDOM % ${#colors[@]}]}
printf '%s\n' "$random_color" | sudo tee /sys/devices/platform/clevo_keyboard/color_left >/dev/null
printf '%s\n' "$random_color" | sudo tee /sys/devices/platform/clevo_keyboard/color_center >/dev/null
printf '%s\n' "$random_color" | sudo tee /sys/devices/platform/clevo_keyboard/color_right >/dev/nul
printf '%s\n' "$random_color" | sudo tee /sys/devices/platform/clevo_keyboard/color_extra >/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment