[Notes] Chakra Linux on MacBook Pro

Notes of installing Chakra Linux (2017/10) on MacBook Pro (2015-mid)

Disk Partition

My usage senario

  1. Left macOS (currently High Sierra + APFS) minimun required space to upgrade itself.
  2. Defaultly enter Linux when booting.
  3. Enter macOS by press alt key when booting.

Step 1: macOS’s DiskUtility.app

Use macOS to resize APFS partition.

  1. Ensure FileVault has been disabled and decryption is finished. (I doesn’t try to skip this step so I don’t know what will happen if not)
  2. Left default 200MB EFI System Partition (ESP) untouched.
  3. Resize original macOS’ APFS partition until 20GB free space left for system upgrading.
  4. Created a FAT32 partition on all remained unallocated space.

Step 2: Partition within Chakra installation:

  1. Delete the FAT32 partition just created.
  2. Except for ~500MB space lefted unallocated, create & mount your / and /home partition.
  3. Create a ~500MB FAT32 partition, mount to /boot/efi, add flags boot and esp.

My example:

MountPoint  Number  Start   End     Size    File system  Name                  Flags
            1       20.5kB  210MB   210MB   fat32        EFI System Partition  boot, esp
            2       210MB   90.9GB  90.7GB  apfs         Macintosh HD
/home       3       90.9GB  216GB   125GB   ext4
/           4       216GB   250GB   34.0GB  ext4
/boot/efi   5       250GB   251GB   472MB   fat32                              boot, esp

Wifi

MacBook Pro mid-2015 use BCM43602 network card:

$ lspci | grep Network
03:00.0 Network controller: Broadcom Corporation BCM43602 802.11ac Wireless LAN SoC (rev 01)
$ dmesg | grep brcm
$ lsmod | grep brcmfmac

According to Arch Wiki, this card should has been supported by kernel itself (brcmfmac).

I don’t know why it doesn’t enabled out-of-box, but it still can be enabled manually:

modprobe brcmfmac

Auto start after booting

echo brcmfmac > /etc/modules-load.d/brcmfmac.conf

Trouble shooting: Still not works after adding .conf into modules-load.d?

It’s possible that brcmfmac was added into blacklist in modprobe.d.
According to the man page of modprobe.d, modprobe.d is located at:

  • /lib/modprobe.d/*.conf
  • /etc/modprobe.d/*.conf
  • /run/modprobe.d/*.conf

Ensure brcmfmac is not be added into blacklist by any .conf file. (That is to say, if you find blacklist brcmfmac, remove that line.)

Cannot suspend

This is Source

Add to rc.local

1
2
3
4
#!/bin/sh -e
echo LID0 > /proc/acpi/wakeup
echo XHC1 > /proc/acpi/wakeup
exit 0

fn key + F1 ~ 12

Test

echo 2 > /sys/module/hid_apple/parameters/fnmode

Permanently:

echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple_fnmode.conf

Reboot, done!

Input Method (fcitx)

https://wiki.chakralinux.org/index.php?title=Fcitx#CTRL.2BSpace_does_not_work

If you cannot invoke fcitx when Ctrl + Space, but fcitx runs in background without problem, please check your locale, and make sure your locale is un-commented in /etc/locale.gen.

If you sure locale is correct, run fcitx-diagnose to see what should added to ~/.xprofile.

Hi-res Display (Hi-DPI / Retina)

KDE system settings

  • Fonts -> Font
    • Leave Font’s DPI untouched (96)
    • Adjust all fonts -> Set size to 14.0
    • Minimun set to 12.0
      • 96 font DPI seems to be default value. Not recommend to increase font’s DPI for enlarging text, because this make GDK_DPI_SCALE a mess.
  • Display and Monitor -> Displays
    • Click Scale Display, adjust to 1.0
  • Icon -> Icon
    • Detail Options -> customize icon sizes

~/.xprofile

1
2
3
4
5
6
7
8
9
10
11
12
# === Qt =========================================
# QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
export QT_AUTO_SCREEN_SCALE_FACTOR=1

# This is disastrous, don't use.
# export QT_SCALE_FACTOR=2

# === GTK =========================================
export GDK_SCALE=1.5
export GDK_DPI_SCALE=1.5
export CLUTTER_SCALE=1.5
export ELM_SCALE=1.5

Adjusting Scale Display to 1.3 will cause Konsole’s display broken.

  • KDE system settings -> Fonts -> Font
    • Set Font’s DPI to 148
  • Display and Monitor -> Displays
    • Click Scale Display, adjust to 1.3

Icons size on Plasma’s System Tray

Open ~/.config/plasma-org.kde.plasma.desktop-appletsrc, find a section looks like this, a lot of items:

1
2
3
4
[Containments][8][General]
extraItems=org.kde.plasma.printmanager,org.kde.plasma.devicenotifier,org.kde.kupapplet,org.kde.ktp-contactlist,org.kde.plasma.volume,org.kde.plasma.bluetooth,org.kde.plasma.battery,org.kde.plasma.mediacontroller,org.kde.plasma.networkmanagement,org.kde.plasma.clipboard,org.kde.plasma.notifications,org.kde.kdeconnect
knownItems=org.kde.plasma.printmanager,org.kde.plasma.devicenotifier,org.kde.kupapplet,org.kde.ktp-contactlist,org.kde.plasma.volume,org.kde.plasma.bluetooth,org.kde.plasma.battery,org.kde.plasma.mediacontroller,org.kde.plasma.networkmanagement,org.kde.plasma.clipboard,org.kde.plasma.notifications,org.kde.kdeconnect
(......)

Append one line in this section:

iconSize=2

Give it values from 0 to 5 which correspond to the size Small, SmallMedium, Medium, Large, Huge, Enormous respectively.

Save file, Alt + F2 kquitapp plasmashell;kstart plasmashell to apply.

kquitapp can also be kquitapp5 or killall

SSH Agent

Method 1: ssh-agent + ssh-add + ksshaskpass

Use ssh-agent to cache your SSH passphrase when login into KDE, so you needn’t enter passphrase whenever git push.

  1. Install ksshaskpass
  2. Edit (if not exist, create it) ~/.xprofile (or ~/.xinitrc), add following 3 lines:

    export SSH_ASKPASS="/usr/bin/ksshaskpass"
    eval $(ssh-agent)
    
  3. Add ssh-add into KDE System Setting -> Startup and Shutdown -> Autostart -> Add Program...

I don’t recommend to place ssh-add also into ~/.xprofile, because when you login from SDDM, you cannot use the saved passphrase in (locked) KWallet.

freedesktop.org standard directories

Run xdg-user-dirs-update, then ~/Picture, ~/Movie… generated. See https://wiki.archlinux.org/index.php/XDG_user_directories

monospace font in Konsole

See my another article configure monospace fonts for terminal

Firefox

  • Install hunspell and its directories for Firefox’s spell checking

[TODO] Encrypt Home

suspend

SYSTEMD_LOG_LEVEL=debug systemctl status mbp-suspend.service

[FIXME] SD Card Reader

Just buy a USB external SD card reader to solve this shit.

dmesg | grep SD

[    1.084301] scsi 0:0:0:0: Direct-Access     ATA      APPLE SSD SM0256 SA0Q PQ: 0 ANSI: 5
[    1.975499] scsi 1:0:0:0: Direct-Access     APPLE    SD Card Reader   3.00 PQ: 0 ANSI: 6
[12968.934410] scsi 1:0:0:0: Direct-Access     APPLE    SD Card Reader   3.00 PQ: 0 ANSI: 6

[FIXME] ctrl alt super (scancode -> keycode conversion)

I still not found the solution for this need. I’ve asked and been waiting for answser on StackExchange

See https://wiki.archlinux.org/index.php/Map_scancodes_to_keycodes

Generic input devices (also USB keyboards) identified by the usb kernel modalias:

evdev:input:bBUSIDvVENDORIDpPRODUCTIDeVERSION-MODALIAS

1. Find the vendor id / product id / version of build-in keyboard:

Run less /proc/bus/input/devices and find section like this:

I: Bus=0003 Vendor=05ac Product=0274 Version=0110
N: Name="Apple Inc. Apple Internal Keyboard / Trackpad"
P: Phys=usb-0000:00:14.0-12/input1
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.1/0003:05AC:0274.0004/input/input7
U: Uniq=D3H624316K1FTV4A63PS
H: Handlers=sysrq kbd leds event7
B: PROP=0
B: EV=120013
B: KEY=10000 0 0 0 1007b00011007 ff9f217ac14057ff ffbeffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=1f

2. Get scancodes

Run showkey --scancodes in TTY:

scancode (hex) keycode
capslock 3a ba 58
———– —————- ———
fn – – 464
leftctrl 1d 9d 29
leftalt 38 b8 56
leftmeta e0 5b e0 db 125
———– —————- ———
r_control e0 5c e0 dc 126
r_alt e0 38 e0 b8 100

3. Create config file in /etc/udev/hwdb.d/

/etc/udev/hwdb.d/10-apple-kb.hwdb

1
2
3
4
5
6
7
evdev:input:b0003v05acp0274e0110*
KEYBOARD_KEY_3aba=leftctrl
KEYBOARD_KEY_1d9d=leftctrl
KEYBOARD_KEY_38b8=leftmeta
KEYBOARD_KEY_e05be0db=leftalt
KEYBOARD_KEY_e05ce0dc=rightctrl
KEYBOARD_KEY_e038e0b8=rightalt