Last active
April 16, 2019 16:13
-
-
Save duckythescientist/626c532676bfd9345cbd78298024a066 to your computer and use it in GitHub Desktop.
Fix my monitors and touchpad because Linux doesn't work on laptops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cachedir="${XDG_CACHE_HOME:-$HOME/.cache}" | |
synclient ClickFinger3=2 | |
synclient TapButton3=2 | |
synclient EmulateMidButtonTime=50 | |
pkill syndaemon | |
syndaemon -d -t -K -i 1.0 | |
# # Mouse acceleration | |
# mousedev=$(xinput | grep "Logitech M705" | cut -d'=' -f 2 | cut -f 1) | |
# # xinput set-prop $mousedev 286 0.5 | |
# xinput set-prop $mousedev 621 0.5 | |
# property number keeps changing.... | |
# Map touchscreen to laptop display | |
main_screen="$(xrandr | grep -o -E -m 1 'eDP[-0-9]*\b')" | |
for d in $(xinput | grep "Wacom HID" | cut -d'=' -f 2 | cut -f 1); do | |
xinput map-to-output "$d" "$main_screen" | |
done | |
# Do special things if this script is run twice in a short time period | |
lastrun="$(cat $cachedir/fix.sh.lastrun 2>/dev/null)" | |
lastrun="${lastrun:-0}" | |
thisrun="$(date -u +%s)" | |
echo "$thisrun" > "$cachedir/fix.sh.lastrun" | |
if (( "$thisrun" - "$lastrun" < 10 )); then | |
# echo "Doing special things" | |
# Laptop screen fails to come on by itself. Fix. | |
xrandr --output "$main_screen" --off | |
sleep 1 | |
fi | |
# Sometimes the monitor numbers get flipped | |
# run `fix.sh f` to flip | |
flipfile="$cachedir/fix.sh.monflip" | |
if [ ! -f "$flipfile" ]; then | |
echo "prepopulating flipfile" | |
echo "mon1=\"1\"" > "$flipfile" | |
echo "mon2=\"2\"" >> "$flipfile" | |
fi | |
source "$flipfile" | |
if [ "$1" = "f" ]; then | |
echo "mon1=\"$mon2\"" > "$flipfile" | |
echo "mon2=\"$mon1\"" >> "$flipfile" | |
source "$flipfile" | |
fi | |
# Monitor configuration | |
case "$(prime-select query)" in | |
nvidia) | |
# Triple monitor (nvidia) | |
xrandr --output eDP-1-1 --auto --pos 2160x1400 \ | |
--output "DP-1-${mon1}-2" --auto --pos 0x0 --rotate left \ | |
--output "DP-1-${mon2}-2" --auto --pos 6000x1400 --rotate inverted | |
;; | |
intel) | |
# Dual monitor (intel) | |
xrandr --output eDP-1 --auto --pos 2160x1400 \ | |
--output DP-2-2 --auto --pos 0x0 --rotate left \ | |
--output DP-1-2 --off | |
;; | |
*) | |
echo "UNKNWON PRIME MODE" | |
;; | |
esac | |
# systemd-udevd high cpu because of nvidia bullshit | |
# https://askubuntu.com/a/1074839 | |
sudo systemctl stop systemd-udevd systemd-udevd-kernel.socket systemd-udevd-control.socket | |
sudo systemctl start systemd-udevd systemd-udevd-kernel.socket systemd-udevd-control.socket |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment