Skip to content

Instantly share code, notes, and snippets.

@KAIYOHUGO
Last active May 25, 2024 15:47
Show Gist options
  • Save KAIYOHUGO/6c8fc6a94822c61eaecbfe7346b90e77 to your computer and use it in GitHub Desktop.
Save KAIYOHUGO/6c8fc6a94822c61eaecbfe7346b90e77 to your computer and use it in GitHub Desktop.
Pop OS install script for ASUS CX5500

POP OS all in one script for ASUS CX5500

This is some note & script help me setting up pop os on ASUS CX5500.

If you have ASUS CX5500 you can download all and run sudo bash install-all.sh on pop os.

Alought this is for ASUS CX5500 but it should working on most of 2 in 1 laptop. (With some modify

Status

✅:ok ❌:not working ⚠️:working (kind of) ❓:not sure

  • ✅ Wayland
  • ✅ Touch board
  • ✅ Keyboard
  • ✅ Webcam
  • ❌ Deep sleep (not working even on chrmeos)
  • ✅ Speaker (with script below)
  • ✅ Microphone (with script below)
  • ⚠️ Tablet Mode
    • ✅ Disable keyboard & touch board when tablet mode (with script below + Wayland)
    • ✅ Rotation (with config)
    • ❌ Auto correct rotation
  • ✅ Stylus
    • ✅ Draw
    • ✅ Pressure sensitivity

Fix Rotation

Note This should be fix in new release of hwdb. For ASUS CX5500 you can replace lib/udev/hwdb.d/60-sensor.hwdb with new one then run update command.

systemd-hwdb update
udevadm trigger

First check ACCEL_MOUNT_MATRIX

udevadm info -n /dev/iio:device{device number here}

For me it look like this

udevadm info -n /dev/iio:device2

Output

P: /devices/{A lot stuff}/iio:device2
N: iio:device2
...
E: ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, -1, 0; 0, 0, -1
...

If you don't know the number you can check the log of iio-sensor-proxy

journalctl -b -u iio-sensor-proxy.service

Output

Aug 22 17:04:57 pop-os iio-sensor-prox[693]: Could not find trigger name associated with /sys/devices/{A lot stuff}/iio:device2
Aug 22 17:04:59 pop-os iio-sensor-prox[693]: driver_set_polling: assertion 'sensor_device' failed

Follow the instruction in the beginning of HWDB ,replace device0 with device{the number you find}.

Don't forget to update the and check ACCEL_MOUNT_MATRIX is correct with first command

systemd-hwdb update
udevadm trigger

Keymap

First you need disable default super key behavior.

# from https://www.reddit.com/r/pop_os/comments/onp6hv/popos_2104_disable_overlay_key_the_super_key/h5terf4/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
gsettings set org.gnome.mutter overlay-key ''

Revert

# from https://www.reddit.com/r/pop_os/comments/onp6hv/popos_2104_disable_overlay_key_the_super_key/h5terf4/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
gsettings reset org.gnome.mutter overlay-key

Then you need download & extract xremap to this folder.

bash install-keymap.sh
#!/bin/bash
sudo apt update
sudo apt upgrade -y
bash install-tablet.sh
bash install-audio.sh
bash install-wayland.sh
#!/bin/bash
# from https://github.com/WeirdTreeThing/chromebook-linux-audio
curl https://github.com/WeirdTreeThing/chromebook-linux-audio/archive/refs/heads/main.zip -L --output audio_tmp
unzip audio_tmp
cd chromebook-linux-audio-main
./setup-audio
#!/bin/bash
sudo sed -i 's/<!-- Allow everything to be sent -->/<allow user="root"\/>/' /usr/share/dbus-1/session.conf
sudo mkdir /opt/keymap
sudo mv xremap /opt/keymap/
sudo chmod +x /opt/keymap/xremap
sudo mv keymap.yml /opt/keymap/
sudo mv keymap.service /etc/systemd/system/
sudo chmod 644 /etc/systemd/system/keymap.service
sudo systemctl daemon-reload
sudo systemctl enable keymap
sudo systemctl start keymap
#!/bin/bash
# from https://github.com/pimlie/ubuntu-mainline-kernel.sh
sudo apt install wget -y
wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
chmod +x ubuntu-mainline-kernel.sh
sudo mv ubuntu-mainline-kernel.sh /usr/local/bin/
#!/bin/bash
sudo apt install ruby libinput-tools -y
sudo mkdir /opt/tablet
sudo mv watch_tablet /opt/tablet/
sudo chmod +x /opt/tablet/watch_tablet
sudo mv watch_tablet.yml /opt/tablet/
sudo mv tablet.service /etc/systemd/system/
sudo chmod 644 /etc/systemd/system/tablet.service
sudo systemctl daemon-reload
sudo systemctl enable tablet
sudo systemctl start tablet
#!/bin/bash
sudo sed 's/WaylandEnable=false/WaylandEnable=true/' -i '/etc/gdm3/custom.conf'
sudo systemctl restart gdm
[Unit]
Description=Keymap Sevice
[Service]
Type=simple
ExecStart=/opt/keymap/xremap /opt/keymap/keymap.yml
Restart=always
[Install]
WantedBy=multi-user.target
modmap:
- name: Rebind Unrecongized Key
remap:
# set F13 as fulscreen shortcut in setting
ZOOM: F13
SCALE: KEY_TOUCHPAD_TOGGLE
keymap:
- name: Function Key
remap:
SUPER-1: F1
SUPER-2: F2
SUPER-3: F3
SUPER-4: F4
SUPER-5: F5
SUPER-6: F6
SUPER-7: F7
SUPER-8: F8
SUPER-9: F9
SUPER-0: F10
SUPER-MINUS: F11
SUPER-EQUAL: F12
SUPER-BRIGHTNESSDOWN: KBDILLUMDOWN
SUPER-BRIGHTNESSUP: KBDILLUMUP
- name: Other
remap:
SUPER-C: CAPSLOCK
[Unit]
Description=Tablet Sevice
[Service]
Type=simple
ExecStart=/opt/tablet/watch_tablet
Restart=always
[Install]
WantedBy=multi-user.target
#!/usr/bin/env ruby
# from https://github.com/alesya-h/linux_detect_tablet_mode/tree/master
require 'yaml'
def die(msg); puts msg; exit 1; end
def load_config!
@config = YAML.load(File.read("/opt/tablet/watch_tablet.yml"))
unless @config['input_device']
die "Please specify input_device in the config file"
end
end
def config
load_config! unless @config
@config
end
def activate_mode(mode)
puts "Switching to #{mode} mode"
if cmds = config['modes'][mode]
cmds.each{|cmd| system cmd }
end
end
def run_watcher
in_tablet_mode = 0
cmd = "stdbuf -oL -eL libinput debug-events --device #{config['input_device']}"
io = IO.popen(cmd,"r")
while s=io.gets
if m=s.match(/switch tablet-mode state (\d+)/)
case d=m[1].to_i
when 0 then activate_mode "laptop"
when 1 then activate_mode "tablet"
end
else
if m=s.match(/pressed/)
case in_tablet_mode
when 1
activate_mode "laptop"
in_tablet_mode = 0
when 0
activate_mode "tablet"
in_tablet_mode = 1
end
end
end
end
rescue Interrupt
io.close
end
run_watcher
input_device: /dev/input/by-path/pci-0000:00:15.1-platform-i2c_designware.1-event
modes:
laptop:
- gsettings set org.gnome.desktop.peripherals.touchpad send-events 'enabled'
- gsettings set org.gnome.desktop.peripherals.keyboard send-events 'enabled'
tablet:
- gsettings set org.gnome.desktop.peripherals.touchpad send-events 'disabled'
- gsettings set org.gnome.desktop.peripherals.keyboard send-events 'disabled'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment