⟅ About ⟆ Leon van Kammen micro devtrepeneur / web integration ninja from Europe

Chromebook survival guide for linux nodejs developers

Hi! In this post I'm discussing my experiences with the acer chromebook 14 as a developer.

Why did i move to chromebook?

Well, basically curiosity, and my quest for:

But most importantly:

I googled/youtubed people who were running dockers and ubuntu in a chroot, so i figured there’s plenty room for desktop apps if needed.

This took me 5 mins after I got my chromebook:

Ok..it wasn’t exactly 5 minutes ;)

Boom! I was amazed to see that I could continue working on my projects already!

After some days:

What did i tweak after receiving my acer chromebook 14?

What i love so far

What I tried/used to use, but abandoned

What Why
chromebrew Eventhough it worked pretty well, I prefer crouton since it runs in it’s own directory, rather than trying to mix software into Google’s local OS.
tmux I had some copy/paste issues, so I went for a lean-and-mean crosh-approach: CTRL-ALT-T (opens terminaltab) + fullscreen-button = PERFECT. CTRL-1..9 allows me to switch terminals
linux desktop applications eventhough LXDE/XFCE/KDE etc was easy to install using crouton, i didn’t find myself needing it. In some rare cases i still can run GIMP or blender, but the usual image-editing tasks (rotate/crop/resize) can be done using imageviewer of chromeos’s filemanager. I found jwm (Joe’s windowmanager) a far better choice compared to LXDE/XFCE/KDE etc, since i don’t need a second full-fledged windowmanager next to the awesome Chromeos.

What I didn’t try yet

running docker using RKT

Aliases

Im using these alias in my ~/.bashrc for crosh:

alias ubuntu="sudo enter-chroot"
alias startx="sudo enter-chroot xinit"
alias enable_playstore="sudo bash ~/Downloads/enable_playstore"
# cpu-friendly cp for big files
alias cp="bash ~/Downloads/cp.sh"

Awesome javascript editor: Caret-T

UPDATE: I’m using the ‘sources’-tab in chrome devtools as my main editor now (see snapshot below). It integrates perfectly with the Crosh (crouton) shell:

Before that, I tried this chrome app which has intelli-sense

I realized the codecompletion works ultrafast in(side) chrome for obvious reasons :D

Make sure you mount the chroot filesystem in your filemanager as shown in the video, or (ultimately) store all your sourcecode on an tiny usbstick.

Terminal tweaks?

Vim tweaks

Some chrome-shortcuts (Ctrl-w) conflicted with my VIM settings. Therefore i made these changes to ~/vim/vimrc, to make things comfortable:

	" chromebook fix: crouton/ubuntu hints vim to use latin
	set encoding=utf8

	" chromebook: switch windows with alt-arrowkeys instead of ctrl-w
	nmap \ <C-w>w
	nmap \| :tabnew:<CR>
	nmap [ :tabp<CR>
	nmap ] :tabn<CR>

	" save on ctrl-s
	noremap <silent> <C-S>          :update<CR>
	vnoremap <silent> <C-S>         <C-C>:update<CR>
	inoremap <silent> <C-S>         <C-O>:update<CR>

ctrl-w (switch buffer) became a dangerous shortcut, it abruptly closes the chrome tab including terminal and vim :D

Tweak for transferring big files (prevents cpu hogs)

Sometimes I download movies from streaming moviesites (for travelling/offline purposes etc). Somehow using cp caused cpu spikes (MMC storage related?), but i solved that with this script:

#!/bin/bash
# makes transferring big files cpu-friendly on chromebook
#
# usage:
#
#   put this script into ~/Downloads/cp.sh and put this in your ~/.bashrc :
#
#     alias cp='bash ~/Downloads/cp.sh'
#
[[ ! -n $1 ]] && { /bin/cp; exit 0; }
FILESIZE=$(( $( stat -c '%s' "$1" ) / 1024 / 1024 ))
if [[ $FILESIZE -lt 50 ]]; then
  /bin/cp "$@"
else
  nice -n 20 ionice -c 3 /bin/cp "$@"
fi

Voila, this will automatically apply nice and ionice to the cp command (when files are bigger than 50MB). You could apply the same technique to other cpu-heavy commands.

HINT: also do this in your crouton chroots

My /etc/rc.local

Crouton loads /etc/rc.local upon launch, which allows me to trigger these badboys:

# allow linux apps to use ALSA
chmod a+rw /dev/snd/seq

# allow lots of open inodes (webpack/gulp/nodemon etc)
sysctl fs.inotify.max_user_watches=1048576

# uncomment this to disable ssh
#mkdir -p -m0755 /var/run/sshd
#/usr/sbin/sshd

# allow incoming traffic to ports (handy to test webdev on smartphone etc)
/sbin/iptables -P INPUT ACCEPT

# remount so that usb has exec access
mount -o remount,exec,noatime /media/removable/data

# start cron
exec cron

Middleclick paste for xterm on chromebook crouton X11 chroot

I rewired ‘shift-backspace’ to paste in xterm, by putting this script into middleclick.sh:

#!/bin/bash
xdotool mousedown --clearmodifiers 2
xdotool mouseup 2
xdotool keyup alt
xdotool keyup ctrl
xdotool keyup shift

And invoking it using this .xbindkeysrc file in my homedir:

"/home/sqz/bin/middleclick"
    Shift + BackSpace

Running android apps

UPDATE: these days you don’t need this, you can just enable the beta-channel and the playstore pops up

I was able to get android apps quickly up and running by putting this script in Downloads/enable_playstore.sh:

#!/bin/bash
if [[ $(whoami) == "root" ]]; then
  #echo '--enable-arc' > /usr/local/chrome_dev.conf
  echo '--arc-availability=officially-supported' > /usr/local/chrome_dev.conf
  mount -o bind /usr/local/chrome_dev.conf /etc/chrome_dev.conf
  echo now press ctrl-shift-qq and the playstore should show up
else
  echo "must be root"
fi

I didn’t make this a permanent change, as i would like the OS to keep receiving its updates. Also, most applications i use on android, also have a web- or chrome app variant (skype etc).

comments powered by Disqus