Advertisement
DrRaccoon

gpd-xorg-rotation-config

Apr 19th, 2022
2,889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # -*- mode: sh; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
  3. # vim: et sts=4 sw=4
  4.  
  5. #  SPDX-License-Identifier: LGPL-2.1+
  6. #
  7. #  Copyright © 2019,2021 Collabora Ltd.
  8. #  Copyright © 2019,2021 Valve Corporation.
  9. #
  10. #  This file is part of steamos-customizations.
  11. #
  12. #  steamos-customizations is free software; you can redistribute it and/or modify
  13. #  it under the terms of the GNU Lesser General Public License as published
  14. #  by the Free Software Foundation; either version 2.1 of the License, or
  15. #  (at your option) any later version.
  16.  
  17. set -eu;
  18.  
  19. GPD=;
  20. DEBUG=0;
  21. XORG_CONF_FILE=/etc/X11/xorg.conf.d/40-rotation-quirk.conf;
  22. XORG_CONF_TEXT=$(cat - <<EOF
  23. Section "Monitor"
  24.   Identifier "eDP-1"
  25.   Option     "Rotate"        "right"
  26.   Option     "PreferredMode" "720x1280"
  27. EndSection
  28.  
  29. Section "InputClass"
  30.   Identifier   "pointer:Goodix Capacitive TouchScreen"
  31.   Option       "Transformation Matrix" "0 1 0 -1 0 1 0 0 1"
  32.   MatchProduct "Goodix"
  33. EndSection
  34. EOF
  35.               );
  36.  
  37. DEVICE_TEST=$(cat - <<EOF
  38. # this test block detects a thinkpad x220 which I use for
  39. # testing when I don't have a GPD: edit to match your own hw
  40. dmi  system-manufacturer               EQ  LENOVO
  41. dmi  system-product-name               EQ  42914CG
  42. dmi  system-version                    EQ  ThinkPad\\ X220
  43. file /sys/class/drm/card0-LVDS-1/modes EQ  1366x768
  44. dmi  bios-release-date                 IN  07/18/2013
  45. EOF
  46.             );
  47. DEVICE_GPD=$(cat - <<EOF
  48. # This test block replicates the logic used by the kernel quirk
  49. # code so if it's wrong we're going to be broken anyway:
  50. dmi  system-manufacturer               EQ  Default\\ string
  51. dmi  system-product-name               EQ  Default\\ string
  52. dmi  system-version                    EQ  Default\\ string
  53. file /sys/class/drm/card0-eDP-1/modes  EQ  720x1280
  54. dmi  bios-release-date                 IN  12/07/2017 05/24/2018 06/29/2018
  55. EOF
  56.           );
  57.  
  58. trace ()
  59. {
  60.     if [ "$DEBUG" = "1" ];
  61.     then
  62.         echo "$@" >&2;
  63.     fi;
  64. }
  65.  
  66. add-config ()
  67. {
  68.     local file=$1;
  69.     local text=$2;
  70.  
  71.     mkdir -p $(dirname "$file");
  72.     echo "$text" > "$file";
  73. }
  74.  
  75. del-config ()
  76. {
  77.     local file=$1;
  78.  
  79.     if [ -f "$file" ]; then rm -f "$file"; fi;
  80. }
  81.  
  82. export LC_ALL=C;
  83. export LANG=C;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement