Skip to content

Instantly share code, notes, and snippets.

@pedropombeiro
Last active April 25, 2020 19:40
Show Gist options
  • Save pedropombeiro/42dad23d355a0f53ff0b010112f8a4e2 to your computer and use it in GitHub Desktop.
Save pedropombeiro/42dad23d355a0f53ff0b010112f8a4e2 to your computer and use it in GitHub Desktop.
/lib/systemd/system-sleep/resume-x1-fix.sh
#!/bin/bash
# Makes sure bluetooth service is not running while suspended.
if [ "${1}" == "pre" ]; then
service bluetooth stop
elif [ "${1}" == "post" ]; then
service bluetooth start
fi
#!/bin/bash
set -euox pipefail
IFS=$'\n\t'
#VENDOR="17ef"
VENDOR="1d6b"
#PRODUCT="6047"
PRODUCT="0003"
for DIR in $(find /sys/bus/usb/devices/ -maxdepth 1 -type l); do
if [[ -f $DIR/idVendor && -f $DIR/idProduct &&
$(cat $DIR/idVendor) == $VENDOR && $(cat $DIR/idProduct) == $PRODUCT ]]; then
echo 0 > $DIR/authorized
sleep 0.5
echo 1 > $DIR/authorized
fi
done
#!/bin/sh
if [ "$2" = "suspend" ] || [ "$2" = "resume" ]; then
case "$1" in
post)
# Reset Bluetooth and network service
#sudo systemctl restart NetworkManager & \
#/etc/init.d/bluetooth restart
/usr/bin/autorandr -cf
pulseaudio -k && sudo alsa force-reload
gsettings set com.ubuntu.user-interface scale-factor "{'DP-1': 16, 'eDP-1': 8}"
/usr/local/bin/reset-lenovo-keyboard.sh
# Reconnecting dead trackpad
echo -n "none" | sudo tee /sys/bus/serio/devices/serio1/drvctl
echo -n "reconnect" | sudo tee /sys/bus/serio/devices/serio1/drvctl
#sleep 1
# Disable trackpad middle button
#xinput set-button-map 'Synaptics TM3288-011' 1 1 3 4 5 6 7 >/dev/null
#xinput set-button-map 'TPPS/2 Elan TrackPoint' 1 1 3 4 5 6 7 >/dev/null
# Disabling the memory card reader
echo "2-3" | sudo tee /sys/bus/usb/drivers/usb/unbind
# Reset Yukico
echo '1-2'|sudo tee /sys/bus/usb/drivers/usb/unbind
sleep 1
echo '1-2'|sudo tee /sys/bus/usb/drivers/usb/bind
;;
suspend|hibernate)
;;
esac
fi
@pedropombeiro
Copy link
Author

[Desktop Entry]
Type=Application
Terminal=true
Name=Resume
Exec=sudo /lib/systemd/system-sleep/resume-x1-fix.sh post suspend
Icon=/lib/systemd/system-sleep/reset.png

@pedropombeiro
Copy link
Author

pedropombeiro commented Sep 9, 2018

This file is not needed anymore after BIOS update 1.30, and can be replaced with https://gist.github.com/PombeirP/672de499389d216312fc3d0d6cc2e932. Only trackpad still has issues sometimes and needs to be reset.

@pedropombeiro
Copy link
Author

pedropombeiro commented Dec 11, 2019

/usr/local/bin/reset-lenovo-keyboard.sh
/lib/systemd/system-sleep/bluetooth-suspend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment