#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/led-kb kb-install () { git clone https://github.com/MatMoul/g810-led.git && cd ~/src/g810-led && sudo apt-get install build-essential libusb-1.0-0-dev && make LIB=libusb } alias {k,kub}="kb-from-file ~/kb/kb-full-group.conf" alias kubs="kb-from-file ~/kb/kb-bright-small.conf" kb-engage () { g810-led -c } kb-cleanup () { local black="000000" # don't change into 0 g810-led -gn logo $black g810-led -gn indicators $black g810-led -kn win_right $black } prof_i=0 kb-next-ex () { local profs=(/usr/share/doc/g810-led/examples/sample_profiles/*) kb_prof=$profs[$prof_i] prof_i=$(( ($prof_i + 1) % $#profs )) local f=$profs[$prof_i] echo $f kb-from-file $f } alias knee=kb-next-ex kb-set-key-color () { local key=$1 local color=$2 g810-led -kn $key $color } kb-set-all-color () { local color=$1 g810-led -an $color } kb-set-all-black () { kb-set-all-color 000000 } kb-from-file () { local profile=$1 kb-set-all-black g810-led -p $profile kb-cleanup kb-engage } # individual themes # simple themes, not computed kb-color () { local clr=$1 kb-set-all-color $clr kb-cleanup kb-engage } kb-blue () { kb-color 444488 2> /dev/null } alias b=kb-blue alias bl=bk-blue alias blue=kb-blue kb-green () { kb-color 636e1a } # somewhat computed themes kb-blue-random () { local q=$(( 2 / 3.0 )) local b=$(( RANDOM % 255 )) local l=$(( $b * $q )) local g=$(( RANDOM % $l )) local r=$(( RANDOM % ($l - $g) )) local rx=$(([##16]r)) local gx=$(([##16]g)) local bx=$(([##16]b)) local rgb="${rx}${gx}${bx}" kb-set-all-color $rgb kb-cleanup kb-engage } kb-army-green () { local green=${1:-110} local red=$(( 0.90 * $green )) local blue=$(( 0.24 * $green )) local r=$(([##16]red)) local g=$(([##16]green)) local b=$(([##16]blue)) local rgb="${r}${g}${b}" kb-set-all-color $rgb kb-cleanup kb-engage } alias army=kb-army-green # even more computed themes ... # theme based on hour kb-set-color-hour () { local hour=$(date +"%H") local hours_colors=( ff7f50 fa8072 ffa500 eee8aa ffff00 7cfc00 008000 90ee90 00ff7f 20b2aa 00ffff 40e0d0 b0e0e6 00bfff 87cefa 0000cd 4b0082 9370db 8b008b 800080 ff00ff ff1493 ff69b4 f5f5dc ) local hour_color=$hours_colors[$hour] kb-set-all-color $hour_color kb-cleanup kb-engage } alias kb-hour=kb-set-color-hour # theme based on weekday # this will modify but not completely reset the previous theme kb-set-color-day () { local day=$(date +"%u") local day_color="7f55ff" local day_color_extra="dddddd" local days_keys=(m t w t f s s) local days_keys_extra=(o u e h r a u) local day_key=$days_keys[$day] local day_key_extra=$days_keys_extra[$day] kb-set-key-color $day_key $day_color kb-set-key-color $day_key_extra $day_color_extra } # combine non-computed and computed theme warmy () { army kb-set-color-day kb-engage } # https://www.rapidtables.com/web/color/RGB_Color.html # maroon 800000 # dark red 8b0000 # brown a52a2a # firebrick b22222 # crimson dc143c # red ff0000 # tomato ff6347 # coral ff7f50 # indian red cd5c5c # light coral f08080 # dark salmon e9967a # salmon fa8072 # light salmon ffa07a # orange red ff4500 # dark orange ff8c00 # orange ffa500 # gold ffd700 # dark golden rod b8860b # golden rod daa520 # pale golden rod eee8aa # dark khaki bdb76b # khaki f0e68c # olive 808000 # yellow ffff00 # yellow green 9acd32 # dark olive green 556b2f # olive drab 6b8e23 # lawn green 7cfc00 # chart reuse 7fff00 # green yellow adff2f # dark green 006400 # green 008000 # forest green 228b22 # lime 00ff00 # lime green 32cd32 # light green 90ee90 # pale green 98fb98 # dark sea green 8fbc8f # medium spring green 00fa9a # spring green 00ff7f # sea green 2e8b57 # medium aqua marine 66cdaa # medium sea green 3cb371 # light sea green 20b2aa # dark slate gray 2f4f4f # teal 008080 # dark cyan 008b8b # aqua 00ffff # cyan 00ffff # light cyan e0ffff # dark turquoise 00ced1 # turquoise 40e0d0 # medium turquoise 48d1cc # pale turquoise afeeee # aqua marine 7fffd4 # powder blue b0e0e6 # cadet blue 5f9ea0 # steel blue 4682b4 # corn flower blue 6495ed # deep sky blue 00bfff # dodger blue 1e90ff # light blue add8e6 # sky blue 87ceeb # light sky blue 87cefa # midnight blue 191970 # navy 000080 # dark blue 00008b # medium blue 0000cd # blue 0000ff # royal blue 4169e1 # blue violet 8a2be2 # indigo 4b0082 # dark slate blue 483d8b # slate blue 6a5acd # medium slate blue 7b68ee # medium purple 9370db # dark magenta 8b008b # dark violet 9400d3 # dark orchid 9932cc # medium orchid ba55d3 # purple 800080 # thistle d8bfd8 # plum dda0dd # violet ee82ee # magenta, fuchsia ff00ff # orchid da70d6 # medium violet red c71585 # pale violet red db7093 # deep pink ff1493 # hot pink ff69b4 # light pink ffb6c1 # pink ffc0cb # antique white faebd7 # beige f5f5dc # bisque ffe4c4 # blanched almond ffebcd # wheat f5deb3 # corn silk fff8dc # lemon chiffon fffacd # light golden rod yellow fafad2 # light yellow ffffe0 # saddle brown 8b4513 # sienna a0522d # chocolate d2691e # peru cd853f # sandy brown f4a460 # burly wood deb887 # tan d2b48c # rosy brown bc8f8f # moccasin ffe4b5 # navajo white ffdead # peach puff ffdab9 # misty rose ffe4e1 # lavender blush fff0f5 # linen faf0e6 # old lace fdf5e6 # papaya whip ffefd5 # sea shell fff5ee # mint cream f5fffa # slate gray 708090 # light slate gray 778899 # light steel blue b0c4de # lavender e6e6fa # floral white fffaf0 # alice blue f0f8ff # ghost white f8f8ff # honeydew f0fff0 # ivory fffff0 # azure f0ffff # snow fffafa # black 000000 # dim gray, dim grey 696969 # gray, grey 808080 # dark gray, dark grey a9a9a9 # silver c0c0c0 # light gray, light grey d3d3d3 # gainsboro dcdcdc # white smoke f5f5f5 # white ffffff