Skip to content

Instantly share code, notes, and snippets.

@uogbuji
Forked from cassiozen/pixelbook-dev-setup.md
Last active May 17, 2024 00:35
Show Gist options
  • Save uogbuji/714d06ad3a9e081b69337107a0beff18 to your computer and use it in GitHub Desktop.
Save uogbuji/714d06ad3a9e081b69337107a0beff18 to your computer and use it in GitHub Desktop.
Notes on setting up Pixelbook for development

Pixelbook or Pixel Slate Setup

Partly updated June 2023

General caution: Chrome OS is a secure OS by design, but this has at least one key consequence. If you change your Google account password, you will still be required to enter the old password the next time you access each Chrome OS device. Devices are encrypted with that password, so the OS needs to decrypt using the old password then re-encrypt using the new one. If you forget your old password you will lose access to your Chrome OS device data. As always, make sure you keep backups up to date.

Fast User Switching

If you have multiple Chrome OS accounts (Say, work and play), you can quickly sitch between them without logging out:

  1. Open the status area (the bottom-right menu)
  2. Click your account photo.
  3. Click Sign in another user.
  4. You'll see a reminder to use the feature only with people you trust. Click OK.
  5. Pick a person, then enter their password. You can add up to 7 users. Warning: sme sorts of Google accounts can only be used as the primary (first set up) account on a chromebook.

You can then quick-switch between users with CTRL+ALT+, & CTRL+ALT+.

Enable Power Button as 2FA

Pixelbook's power button (but apparently not the Slate's) has a built-in 2fa/2sv key (think YubiKey), but it's disabled by default. If you use Two-Factor authentication on GitHub, Gmail etc, you can turn it on by entering this command on the Crosh shell (Ctrl+Alt+T):

u2f_flags u2f,user_keys

Linux Setup (AKA Crostini)

Enable Linux Apps

Official instructions

  1. Select the time in the bottom right to open your status area.
  2. Select Settings, then Advanced
  3. Under "Linux development environment" select Turn On.
  4. Follow the steps on the screen. Setup can take 5 minutes or more.
  5. A terminal window opens. You can run Linux commands, install more tools using the APT package manager (see below), and customize your shell.

Initial update of container

sudo apt update && sudo apt dist-upgrade

Note: some guides out there suggest setting the root password, but never do that unless you absolutely know what you're doing. If you need to use a feature that requires a password for root, set it on the Crostini default user instead:

sudo passwd

Dev & general kit

Since you'll probably be doing some sort of software building or development, you should use install relevant packages

sudo apt-get install git build-essential libssl-dev libffi-dev

If you're used to having certain system command line tools handy, you might need to install them on debian. I do:

sudo apt install mtr dnsutils vim nano

Actually I don't usually bother with nano, as I just deal with vim, but if you like that text editor better, it will be installed from the above. These days I use mtr rather than ping & traceroute, but if you want to go old school you can do:

sudo apt install dnsutils traceroute iputils-ping

You might also want some other useful tools. I do:

sudo apt install zip whois tree xclip

Install latest Python

The Debian install on ChromeOS/Linux is "stable", only, and generally has only older Python versions available. We need to add sid for optional installs of more recent software. Step 1 is to add the repository. Edit (using vi or nano), e.g. sudo vi /etc/apt/sources.list and append the following as the new last line:

deb http://http.us.debian.org/debian sid main non-free contrib

Now the next step is important before you do anything more with apt, or you can make quite a mess. We only want to use sid packages if we exlicitly ask for them create a new file, e.g. sudo vi /etc/apt/preferences with the following contents:

Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=testing
Pin-Priority: 650

Package: *
Pin: release a=unstable
Pin-Priority: 600

Now you can install Python 3.11 as follows:

sudo apt -t sid install python3.11

Recent versions of many other packages should now be available.

Set up virtualenv support

Prepare:

mkdir -p $HOME/.local/venv

Make a virtualend called main. Use a different name, if you prefer:

/usr/bin/python3.11 -m venv $HOME/.local/venv/main

You only need to specify the full path to Python when creating the venv, as above.

Activate:

source $HOME/.local/venv/main/bin/activate
pip install --upgrade pip #Needed from time to time, to make sure pip itself is up to date
pip install wheel #One time per venv. Allows pip to install pre-compiled os-specific versions. Also you might get odd errors if you omit this.

In future you only need the first line above to activate the venv.

Generate new SSH Key

I prefer to use an Ed25519 key.

ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "my_name.pixelbook"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat .ssh/id_ed25519.pub
# Paste in GitHub/GitLab/etc.

In order to make sure SSH agent starts automatically, and that only one ssh-agent process runs at a time, add the following to .bashrc:

if ! pgrep -u "$USER" ssh-agent > /dev/null; then
    ssh-agent > ~/.ssh-agent-thing
fi
if [[ ! "$SSH_AUTH_SOCK" ]]; then
    eval "$(<~/.ssh-agent-thing)"
fi

I prefer to just after each restart enter:

ssh-add ~/.ssh/id_ed25519

But there are tools I've used in Linux to automatically pop up a prompt if a key hasn't been registered with the agent.

Python environment

I then follow these Python dev setup steps for Linux

Backup

Warning: Until this bug is addressed Crostini containers only grow in disk space; they never shrink, even if you delete files within them.

The main approach to backup is to export the entire container:

  • Enable the "Crostini Backup" Flag – chrome://flags/#crostini-backup, then choose Restart
  • Open chrome://settings/crostini/exportImport and select "Backup" followed by "Save". Ideally save this on a external drive.

To restore:

  • Open chrome://settings/crostini/exportImport and select "Restore". Select the export archive file. After it's done the exported version of Crostini should be in place.

File Sharing

Now automatic between Chrome OS and Linux. You'll find Linux files/directories in the Files app, under "Linux Files".

In order to access Chrome OS files you must make the desired folder or removable device available to Linux by right clicking in the Files app and selecting the option. Note: It seems you might have to reboot the device before this "Share with Linux" option appears.

Google Drive

Go to the files app and right click on Google Drive, then click "Share with Linux"

Files will be available under: /mnt/chomeos/Googledrive

Slack

Download the Linux package. Install with Linux.

If you just launch & click "Sign in" you'll eventually land at the error: "We’re sorry It looks like you are on a device that we don’t yet support."

Instead just go to https://[your-channel].slack.com/ssb/signin_redirect/fallback, click "Copy sign-in key" then launch slack, which will automatically pick up the magic key from your clipboard. Repeat for any other accounts you have.

Dropbox

Unfortunately Dropbox support for ChromeOS is poor. Main recommendation seems to be the third-party File System for Dropbox but it doesn't support offline access. The official Dropbox Linux client ended support for all file systems except unencrypted ext4, which rules it out for crostini. Looking into rclone and just using the Web client for now.

Skype

I tried the Skype for Linux DEB, but the microphone didn't work on Pixel Slate, and I've heard screen sharing might not work. I might try the Android app, but for now I'm just switching as much as I can to Google Meet.

Applications

Crostini (the Linux container on Chrome OS) understands Debian installation packages (.deb) - You can just download any installer and double-click it to install.

And, being debian you also have apt, though in this case you might need to set up the installed apps to be launched by icon by placing a desktop file in /usr/local/share/applications/. Details here.

sudo mkdir -p /usr/local/share/applications

Some examples next

Terminal alternatives

So many choices, and so manby combos of distinct and/or overlapping and/or complementary tools. I'm trying just Extraterm

Extraterm

mkdir ~/Downloads
cd ~/Downloads
#Update to latest release
wget https://github.com/sedwards2009/extraterm/releases/download/v0.42.2/extraterm-0.42.2-linux-x64.zip
wget https://github.com/sedwards2009/extraterm/releases/download/v0.42.2/extraterm-commands-0.42.2.zip
cd /opt
sudo unzip ~/Downloads/extraterm-0.42.2-linux-x64.zip
sudo unzip ~/Downloads/extraterm-commands-0.42.2.zip
sudo ln -s /opt/extraterm-0.42.2-linux-x64/extraterm /usr/local/bin/
sudo apt install libnss3

Edit (sudo vi /usr/share/applications/extraterm.desktop) to get the launcher in Chrome OS. Contents:

[Desktop Entry]
Name=Extraterm
Keywords=shell;prompt;command;commandline;cmd;
Version=0.42.2
Comment=The swiss army chainsaw of terminal emulators
Exec=/usr/local/bin/extraterm
Icon=/opt/extraterm-0.42.2-linux-x64/resources/app/extraterm/resources/logo/extraterm_small_logo_256x256.png
Type=Application

Add to .bashrc the Extraterm command for shell integration, e.g. add the line:

. /opt/extraterm-commands-0.42.2/setup_extraterm_bash.sh

Note: You would think this should be added to .profile but for some reason Extraterm under Crostini does not run a login shell (i.e. running shopt login_shell yields off).

Tilix

echo 'deb http://ftp.debian.org/debian stretch-backports main' | sudo tee /etc/apt/sources.list.d/stretch-backports.list
sudo apt update
sudo apt -y install tilix
sudo ln -s /etc/profile.d/vte-2.91.sh /etc/profile.d/vte.sh

Add to path

if [ $TILIX_ID ] || [ $VTE_VERSION ]; then
    source /etc/profile.d/vte.sh
fi

Gnome Terminal

sudo apt install gnome-terminal

Also:

  • Terminator
  • mate-terminal
  • combos of the above with tmux or byobu

Text editor/IDE

I was using TextMate on Mac and Atom in my Linux Mint installs. I'm not much of a fan of IDEs, but VSCode seems really popular among Pixelbook users, so I'll give it a whirl.

Atom

Download the .deb installer from atom.io (or the beta version of Atom if you prefer). Click "Show in folder" right click then "Install in Linux"

VSCode

Download via chrome and click through to the download location in Files app. Right click then "Install in Linux"

If you use VSCode for Python dev and want to use VSCode plugins you'll want to do:

sudo apt install python3-pip

Supplementary info

Entering non-ASCII characters

Coming from Mac OS's excellent setup for international character entry I have to say ChromeOS falls quite short. From the commonplace (SHIFT+OPTION+ - = em dash) to the less common (ALT+ e / i / SHIFT+ALT+ x = Igbo nasal i with rising tone) such keyboard shortcuts are nowhere to be found.

Best friend is probably the Unicode entry hotkey CTRL+SHIFT+ u. When you press this you get an underlined u and you can type in a 4 digit hex Unicode value to get the character. Then you just have to remember your faborites (e.g. 2014 = em dash) or print out a chart to have handy. Here is a handy table.

There is the US International Keyboard (add it from the Input Methods menu near the screen bottom right), but if you mix other languages with English, you'll be annoyed e.g. that a regular apostrophe is always an accent acute.

Tip from mannkeithc on Reddit:

Flip your Pixelbook into tablet mode, and use the onscreen virtual keyboard. You can hold down a character key and then slide over to the respective international character you want—very similar to an iPad or Mac OS. Bring this same virtual keyboard onto the screen when you are in clamshell/laptop mode by first selecting "Handwriting input". This brings up a virtual input area. Select the keyboard symbol towards LH top of this window to get the virtual keyboard. You can then use the touch screen as in tablet mode to select the international characters you want.

Clipboard history

On MacOS and Linux I've become used to the convenience of clipboard managers which e.g. allow you to manage a history of cut & paste, which can be very handy especially when editing code. It seems Clipboard History Pro is the favorite choice of ChromeOS power users, but it's not yet entirely growing on mw. The keyboard shortcut doesn't seem to work and some of the other config options seem flaky. One note: it only stores the clipboard in your local browser storage, unless you explicitly upload an item to cloud storage (a useful feature), but I still recommend you never copy sensitive data such as passwords with any such tool.

Using a pen

Pixelbook and Pixel slate are of course touch and pen devices, but you probably don't need to buy Google's $100 pen. You can find the Lenovo Active Pen 1 for about $20 and I was able to buy the Lenovo Active Pen 2 for just over $30. Many reviews indicate that these work as well for all but the most advanced users.

Launch a Chrome browser tab

You can use the standard Python mechanism

python -m webbrowser -t http://www.google.com

Or you can use garcon:

/usr/bin/garcon-url-handler https://www.google.com

If you want to change the browser used, set the BROWSER environment variable.

Install Fonts

Some fonts can be installed using apt, for example I use Inconsolata

sudo apt install fonts-inconsolata -y
sudo fc-cache -fv

If you just have the font file:

  • Copy .ttf file to ~/.local/share/fonts
fc-cache -vf ~/.local/share/fonts
fc-list | grep [your font name] # To verify

HiDPI & Sommelier

The Pixelbook has a high-density display (HiDPI, roughly equivalent to the "Retina display" term if you're comming from a Mac), but not all Linux apps are prepared to appear correctly in HiDPI displays. They can appear small or have regular size with tiny cursor...

The good news is that you can use ChromeOS's built-in tool Sommelier to customize zoom levels for linux applications.

See also this reddit thread.

Example Sommelier setup (with Visual Studio Code)

Many installed programs will generate a .desktop file in /usr/share/applications, it contains an app description as well as its icon and launch command.

Example: /usr/share/applications/code.desktop

Change Exec entries to specify Sommelier's DPI and zoom level:

[Desktop Entry]
Name=Visual Studio Code
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=sommelier -X --scale=0.7 --dpi=160 /usr/share/code/code "--unity-launch %F"
Icon=code
Type=Application
StartupNotify=true
StartupWMClass=Code
Categories=Utility;TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;
Actions=new-empty-window;
Keywords=vscode;

X-Desktop-File-Install-Version=0.23

[Desktop Action new-empty-window]
Name=New Empty Window
Exec=sommelier -X --scale=0.7 --dpi=160 /usr/share/code/code "--new-window %F"
Icon=code

Specifically for VSCode, I would also suggest adding these to your user settings

"window.titleBarStyle": "custom",
"window.zoomLevel": 2,
"editor.mouseWheelScrollSensitivity": 0.5

Key resources

@uogbuji
Copy link
Author

uogbuji commented Jul 6, 2019

@esternin
Copy link

The Pen section is a little too slim, do you (or anybody) know more about the sommelier support for stylus/touchscreen?

As far as I can tell, stylus and touchscreen are not treated by sommelier as separate devices, so in stylus-oriented programs, like xournal/xournalpp, one cannot assign separate devices to zoom/pan (I would want touchscreen to do those) and draw (the stylus device). There is also the eraser device (wacom style), and that would be just a cherry on top, especially if and when the [stupid] Assistant-only button on the Pixelbook pen could be captured and assigned to switch-pen-to-eraser action, or if a pen with an actual active eraser tip could be found for Pixelbook.

Here's what I see in termina (ChromeOS 79, manually updated to buster=Debian 10.2, which will be the default for ChromeOS 80 in a couple of weeks) :

$ ps -ef | grep sommelier
user_name+   121    97  0 12:37 ?        00:00:00 /opt/google/cros-containers/bin/../lib/ld-linux-x86-64.so.2 --library-path /opt/google/cros-containers/bin/../lib --inhibit-rpath  /opt/google/cros-containers/bin/sommelier.elf -X --x-display=0 --sd-notify=READY=1 --no-exit-with-child --x-auth=/home/user_name/.Xauthority /bin/sh -c systemctl --user set-environment DISPLAY=${DISPLAY};                     systemctl --user set-environment XCURSOR_SIZE=${XCURSOR_SIZE};                     systemctl --user import-environment SOMMELIER_VERSION;                     touch /home/user_name/.Xauthority;                     xauth -f /home/user_name/.Xauthority add :0 . $(xxd -l 16 -p /dev/urandom);                     . /etc/sommelierrc
user_name+   122    97  0 12:37 ?        00:00:00 /opt/google/cros-containers/bin/../lib/ld-linux-x86-64.so.2 --library-path /opt/google/cros-containers/bin/../lib --inhibit-rpath  /opt/google/cros-containers/bin/sommelier.elf --master --sd-notify=READY=1 --socket=wayland-1 /bin/sh -c systemctl --user set-environment WAYLAND_DISPLAY_LOW_DENSITY=${WAYLAND_DISPLAY};                     systemctl --user import-environment SOMMELIER_VERSION
user_name+   123    97  0 12:37 ?        00:00:00 /opt/google/cros-containers/bin/../lib/ld-linux-x86-64.so.2 --library-path /opt/google/cros-containers/bin/../lib --inhibit-rpath  /opt/google/cros-containers/bin/sommelier.elf --master --sd-notify=READY=1 --socket=wayland-0 /bin/sh -c systemctl --user set-environment WAYLAND_DISPLAY=${WAYLAND_DISPLAY};                     systemctl --user import-environment SOMMELIER_VERSION
user_name+   125    97  0 12:37 ?        00:00:00 /opt/google/cros-containers/bin/../lib/ld-linux-x86-64.so.2 --library-path /opt/google/cros-containers/bin/../lib --inhibit-rpath  /opt/google/cros-containers/bin/sommelier.elf -X --x-display=1 --sd-notify=READY=1 --no-exit-with-child --x-auth=/home/user_name/.Xauthority /bin/sh -c systemctl --user set-environment DISPLAY_LOW_DENSITY=${DISPLAY};                     systemctl --user set-environment XCURSOR_SIZE_LOW_DENSITY=${XCURSOR_SIZE};                     systemctl --user import-environment SOMMELIER_VERSION;                     touch /home/user_name/.Xauthority;                     xauth -f /home/user_name/.Xauthority add :1 . $(xxd -l 16 -p /dev/urandom);                     . /etc/sommelierrc

$ xinput
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ xwayland-pointer:7                      	id=6	[slave  pointer  (2)]
⎜   ↳ xwayland-relative-pointer:7             	id=7	[slave  pointer  (2)]
⎜   ↳ xwayland-touch:7                        	id=9	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ xwayland-keyboard:7                     	id=8	[slave  keyboard (3)]

Is there perhaps some sommelier configuration option that could be added to resolve this?

@uogbuji
Copy link
Author

uogbuji commented Jan 21, 2020

Hi @esternin. You're right that I didn't spend much time on pen input. I'm not a heavy pen user, though I do have a Lenovo Stylus, mostly for filling and signing forms, so just Chrome and the native PDF app—No Linux apps. If you figure this out I'd be happy to add a section, with credit to you, or you could also fork the doc and issue a PR later. I wasn't able to find many hints on a quick googling, which I'm sure you already tried, anyway. I'd suggest asking on Reddit r/Pixelbook.

@esternin
Copy link

Thanks. I'll just add it here, in comments, if I figure it out. From reviewing Reddit r/Pixelbook I see that the pen/stylus is a very low priority at google, and the majority of users either use a pen, or Linux, never pen/stylus under Linux. And the problem is not limited to google hardware (I test using a Pixelbook, and a Samsung Chromebook Plus, with identical results), it's crostini interface that is the problem.

It is frustrating that the best Linux+pen software (xournal/xournal++) that I have been using for 15 years to take notes, mark up PDF, and deliver talks and lectures, a true replacement for a chalkboard/whiteboard, is limited by the deficiencies of the Chrome<->crostini interface. I have Wacom Cintiq's in my office and many of our classrooms, and xournal is installed on every lectern computer on campus. I know professional musicians using Chromebook+xournal under crostini to play (and mark up) all of their sheet music.

Unfortunately, xournal is frozen in time. At the same time, xournal++ developers do not recognize the potential of their own software - on a Chromebook. So google is not being asked to improve the interface to crostini. There is a feature request for remapping the Assistant button to a user-defined function within apps, but lack of interest keeps pushing its priority down, so I am not sure it will ever happen.

I was just hoping that someone reading this might know an undocumented switch to sommelier to make its input device recognition work properly for the stylus.

@ursuad
Copy link

ursuad commented Mar 5, 2020

Have you tried changing the user (which by default it's your email address) in Crostini for the penguin container? I've seen someone saying here that if the penguin container doesn't exist, you can create it and set a specific user name at creation time, like this:

crosh> vmc start termina
(termina) chronos@localhost ~ $ run_container.sh --container_name penguin --shell --user cl4rkc4nt

I'm just curious if this will have some other implications down the road and it might help other people as well.

EDIT: I found a good way of changing the username here.

@esternin
Copy link

Typically, modern applications installed through sudo apt-get install... arrive with their own .desktop file, and their .svg icon file. However, crostini currently (ChromeOS 80) does not understand the .svg files, only .png. One workaround is to install the imagemagick tools and render the .svg file provided into all resolutions of .png files required by xwayland. I use the following makepng.sh script to do this:

#!/bin/sh
cd /usr/share/icons/hicolor
for s in ?x? ??x?? ???x???
do
  sudo convert -scale $s scalable/apps/$1.svg $s/apps/$1.png
done	
sudo touch /usr/share/icons/hicolor
gtk-update-icon-cache

Assuming /usr/share/applications/MYAPP.desktop has a line that says Icon=MYAPP, which refers to /usr/share/icons/hicolor/scalable/apps/MYAPP.svg, you call the script as makepng.sh MYAPP.

@avm99963
Copy link

This is a great setup guide, thanks for sharing!

Personally, I didn't know there was an experimental U2F software key, so discovering this was great!

However, it seems like the command to activate the security key is different now, now you should run the following: u2f_flags u2f,user_keys. The command u2f_flags u2f enables the previous software key which is no longer recommended to be used because it has a vulnerability.

More info: https://sites.google.com/a/chromium.org/dev/chromium-os/u2f-ecdsa-vulnerability

@uogbuji
Copy link
Author

uogbuji commented Mar 22, 2020

Thanks @avm99963 for the note and the reference. I can't verify your suggested change because I'm no longer in a situation where I'm using a YubiKey with my Chromebook, but I did read the link and so went ahead and updated the doc.

@librehat
Copy link

The scaling tips work for X perhaps. Any ideas how one can apply DPI and scaling for native wayland GUI apps?

@Firespyer
Copy link

Have you managed to get git installed?

@uogbuji
Copy link
Author

uogbuji commented Mar 8, 2021

Yes, I was able to install git no problem via apt.

@Firespyer
Copy link

@uogbuji what version are you running? I am running into a dependency error trying to install with apt.

@uogbuji
Copy link
Author

uogbuji commented Mar 8, 2021

@Firespyer I don't remember. That was almost a year ago. I ended up switching back to Mac when the new MBPs finally seemed worthwhile. I do still keep an eye on the quite active PixelBook reddit, and that might be your best bet for a solution.

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