Skip to content

Instantly share code, notes, and snippets.

@hansemro
Created June 27, 2025 00:03
Show Gist options
  • Select an option

  • Save hansemro/7d65803d1157cdab15bbba2792f3fa72 to your computer and use it in GitHub Desktop.

Select an option

Save hansemro/7d65803d1157cdab15bbba2792f3fa72 to your computer and use it in GitHub Desktop.
[JetKVM][ATX Power Extension] shell script to power on PC
#!/usr/bin/env sh
# ATX Power Control Extension Board Peripheral
SERIAL_DEV=/dev/ttyS3
# Since the extension board provides power to the jetkvm,
# we can assume the extension is connected over serial.
check_atx_status() {
ATX_STATUS=$((2#$(head -n1 $SERIAL_DEV)))
# Evaluate each bit to active-high state
HDD_LED_STATE=$((($ATX_STATUS & 2#1000) == 0))
PWR_LED_STATE=$((($ATX_STATUS & 2#0100) == 0))
RST_BTN_STATE=$((($ATX_STATUS & 2#0010) > 0))
PWR_BTN_STATE=$((($ATX_STATUS & 2#0001) > 0))
#echo "atx_status=$ATX_STATUS"
}
check_atx_status
if [ $PWR_LED_STATE -eq 0 ]; then
# Release power/reset buttons
printf 'BTN_RST_OFF\n\n' > $SERIAL_DEV
printf 'BTN_PWR_OFF\n\n' > $SERIAL_DEV
sleep 1
check_atx_status
echo "Turning PC on..."
printf 'BTN_PWR_ON\n\n' > $SERIAL_DEV
sleep 1.5
printf 'BTN_PWR_OFF\n\n' > $SERIAL_DEV
# check power status
sleep 1.5
check_atx_status
# return 0 if PC is on and 1 otherwise
return $((!$PWR_LED_STATE))
fi
echo "PC already on"
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment