Skip to content

Instantly share code, notes, and snippets.

@c5e3
Last active October 7, 2025 18:44
Show Gist options
  • Save c5e3/e0264a546b249b635349f2ee6c302f36 to your computer and use it in GitHub Desktop.
Save c5e3/e0264a546b249b635349f2ee6c302f36 to your computer and use it in GitHub Desktop.

Revisions

  1. c5e3 revised this gist May 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion thinkmorse.sh
    Original file line number Diff line number Diff line change
    @@ -79,7 +79,7 @@ parse(){
    done
    }

    leds $off
    led $off
    read -p "enter a word: " input
    echo "blinking \"$input\""
    parse "$input"
  2. c5e3 revised this gist May 8, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions thinkmorse.sh
    Original file line number Diff line number Diff line change
    @@ -79,6 +79,7 @@ parse(){
    done
    }

    leds $off
    read -p "enter a word: " input
    echo "blinking \"$input\""
    parse "$input"
  3. c5e3 revised this gist May 7, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions thinkmorse.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,8 @@ off="\x0a"

    led(){
    echo -n -e $1 | dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=12 count=1 conv=notrunc 2> /dev/null
    # thx to u/vali20
    # https://www.reddit.com/r/thinkpad/comments/7n8eyu/thinkpad_led_control_under_gnulinux/
    }

    dit(){
  4. c5e3 revised this gist May 7, 2018. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions thinkmorse.sh
    Original file line number Diff line number Diff line change
    @@ -6,21 +6,21 @@ modprobe ec_sys write_support=1
    on="\x8a"
    off="\x0a"

    leds(){
    led(){
    echo -n -e $1 | dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=12 count=1 conv=notrunc 2> /dev/null
    }

    dit(){
    leds $on
    led $on
    sleep 0.1
    leds $off
    led $off
    sleep 0.1
    }

    dah(){
    leds $on
    led $on
    sleep 0.3
    leds $off
    led $off
    sleep 0.1
    }

    @@ -82,6 +82,6 @@ echo "blinking \"$input\""
    parse "$input"

    sleep 1
    leds $on
    led $on

    modprobe -r ec_sys
  5. c5e3 revised this gist May 7, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion thinkmorse.sh
    Original file line number Diff line number Diff line change
    @@ -85,4 +85,3 @@ sleep 1
    leds $on

    modprobe -r ec_sys
    modprobe ec_sys write_support=0
  6. c5e3 revised this gist May 7, 2018. 1 changed file with 21 additions and 12 deletions.
    33 changes: 21 additions & 12 deletions thinkmorse.sh
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,26 @@
    #!/bin/bash

    modprobe -r ec_sys
    modprobe ec_sys write_support=1

    on="\x8a"
    off="\x0a"

    leds(){
    for i in 0 7 12 # 0 = power led, 7 = hibernation led, 12 = charging led
    do
    echo $i $1 > /proc/acpi/ibm/led
    done
    echo -n -e $1 | dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=12 count=1 conv=notrunc 2> /dev/null
    }

    dit(){
    leds on
    leds $on
    sleep 0.1
    leds off
    leds $off
    sleep 0.1
    }

    dah(){
    leds on
    leds $on
    sleep 0.3
    leds off
    leds $off
    sleep 0.1
    }

    @@ -28,9 +31,9 @@ morse(){
    "2") dit; dit; dah; dah; dah;;
    "3") dit; dit; dit; dah; dah;;
    "4") dit; dit; dit; dit; dah;;
    "5") dit; dit; dit; dit; dit;;
    "6") dah; dit; dit; dit; dit;;
    "7") dah; dah; dit; dit; dit;;
    "5") dit; dit; dit; dit; dit;;
    "6") dah; dit; dit; dit; dit;;
    "7") dah; dah; dit; dit; dit;;
    "8") dah; dah; dah; dit; dit;;
    "9") dah; dah; dah; dah; dit;;
    "a") dit; dah;;
    @@ -76,4 +79,10 @@ parse(){

    read -p "enter a word: " input
    echo "blinking \"$input\""
    parse "$input"
    parse "$input"

    sleep 1
    leds $on

    modprobe -r ec_sys
    modprobe ec_sys write_support=0
  7. c5e3 revised this gist Feb 12, 2017. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions thinkmorse.sh
    Original file line number Diff line number Diff line change
    @@ -43,12 +43,12 @@ morse(){
    "h") dit; dit; dit; dit;;
    "i") dit; dit;;
    "j") dit; dah; dah; dah;;
    "k") dit; dah; dit; dah;;
    "k") dah; dit; dah;;
    "l") dit; dah; dit; dit;;
    "m") dah; dah;;
    "n") dah; dit;;
    "o") dah; dah; dah;;
    "p") dit; dah; dit;;
    "p") dit; dah; dah; dit;;
    "q") dah; dah; dit; dah;;
    "r") dit; dah; dit;;
    "s") dit; dit; dit;;
    @@ -59,9 +59,10 @@ morse(){
    "x") dah; dit; dit; dah;;
    "y") dah; dit; dah; dah;;
    "z") dah; dah; dit; dit;;
    " ") sleep 0.3;;
    " ") sleep 0.6;;
    #*) echo "done";;
    esac
    sleep 0.2;
    }

    parse(){
    @@ -75,4 +76,4 @@ parse(){

    read -p "enter a word: " input
    echo "blinking \"$input\""
    parse "$input"
    parse "$input"
  8. c5e3 created this gist Feb 12, 2017.
    78 changes: 78 additions & 0 deletions thinkmorse.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    #!/bin/bash

    leds(){
    for i in 0 7 12 # 0 = power led, 7 = hibernation led, 12 = charging led
    do
    echo $i $1 > /proc/acpi/ibm/led
    done
    }

    dit(){
    leds on
    sleep 0.1
    leds off
    sleep 0.1
    }

    dah(){
    leds on
    sleep 0.3
    leds off
    sleep 0.1
    }

    morse(){
    case $1 in
    "0") dah; dah; dah; dah; dah;;
    "1") dit; dah; dah; dah; dah;;
    "2") dit; dit; dah; dah; dah;;
    "3") dit; dit; dit; dah; dah;;
    "4") dit; dit; dit; dit; dah;;
    "5") dit; dit; dit; dit; dit;;
    "6") dah; dit; dit; dit; dit;;
    "7") dah; dah; dit; dit; dit;;
    "8") dah; dah; dah; dit; dit;;
    "9") dah; dah; dah; dah; dit;;
    "a") dit; dah;;
    "b") dah; dit; dit; dit;;
    "c") dah; dit; dah; dit;;
    "d") dah; dit; dit;;
    "e") dit;;
    "f") dit; dit; dah; dit;;
    "g") dah; dah; dit;;
    "h") dit; dit; dit; dit;;
    "i") dit; dit;;
    "j") dit; dah; dah; dah;;
    "k") dit; dah; dit; dah;;
    "l") dit; dah; dit; dit;;
    "m") dah; dah;;
    "n") dah; dit;;
    "o") dah; dah; dah;;
    "p") dit; dah; dit;;
    "q") dah; dah; dit; dah;;
    "r") dit; dah; dit;;
    "s") dit; dit; dit;;
    "t") dah;;
    "u") dit; dit; dah;;
    "v") dit; dit; dit; dah;;
    "w") dit; dah; dah;;
    "x") dah; dit; dit; dah;;
    "y") dah; dit; dah; dah;;
    "z") dah; dah; dit; dit;;
    " ") sleep 0.3;;
    #*) echo "done";;
    esac
    }

    parse(){
    tmp=$1
    for i in $(seq 0 ${#tmp})
    do
    echo "current letter: ${tmp:$i:1}"
    morse ${tmp:$i:1}
    done
    }

    read -p "enter a word: " input
    echo "blinking \"$input\""
    parse "$input"