Skip to content

Commit

Permalink
s76-power-autoprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
majal committed Jun 29, 2023
1 parent 1a50f99 commit 90434e8
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions s76/s76-power-autoprofile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,27 @@
# source $HOME/bin/maj-source

################################################################################
# Power switch script - run once
# Check for udev rules - installs the script to UDEV for activation
################################################################################

udev_file="/etc/udev/rules.d/90-$(basename ${0}).rules"

[ -r "${udev_file}" ] || {
echo
echo "UDEV rules file not found. Installing..."
echo
echo "Writing: ${udev_file}"
echo
echo 'SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="'${0}'"' | sudo tee "${udev_file}"
echo 'SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="'${0}'"' | sudo tee -a "${udev_file}"
echo
echo "$ cat ${udev_file}"
cat "${udev_file}"
echo
}

################################################################################
# Power switch script
################################################################################

s76='/usr/bin/system76-power'
Expand All @@ -25,22 +45,3 @@ else
}

fi

################################################################################
# Check for udev rules - installs the script to UDEV for activation
################################################################################

udev_file="/etc/udev/rules.d/90-$(basename ${0}).rules"

[ -r "${udev_file}" ] || {
echo
echo "UDEV rules file not found. Installing..."
echo
echo "Writing: ${udev_file}"
echo 'SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="'${0}'"' | sudo tee "${udev_file}"
echo 'SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="'${0}'"' | sudo tee -a "${udev_file}"
echo
echo "$ cat ${udev_file}"
cat "${udev_file}"
echo
}

0 comments on commit 90434e8

Please sign in to comment.