在MacBook Air M2上使用Asahi Linux和Sway
Asahi Linux with Sway on the MacBook Air M2

原始链接: https://daniel.lawrence.lu/blog/2024-12-01-asahi-linux-with-sway-on-the-macbook-air-m2/

## 新MacBook Air M2 & Asahi Linux 设置 最近购买了一台MacBook Air M2(16GB内存,256GB SSD),价格为750美元,被其性价比所吸引。由于Asahi Linux尚未支持较新的Apple Silicon,初始设置涉及安装Fedora minimal。复制启动镜像的过程出乎意料地慢(~150KB/s)。 安装了定制的Sway桌面环境和必要的工具(fish, neovim等)以及点文件后,注意力转向了显示优化。使用`grubby`的解决方法重新启用了刘海区域周围的屏幕区域,并实施了自定义的Sway bar配置以有效利用该空间。 Asahi Linux的体验非常流畅和响应迅速,甚至超过了强大的AMD Ryzen台式机的性能。触摸板尤其令人印象深刻。尽管存在软件包格式挑战,但该笔记本电脑也成功运行了线扫描摄影软件(Alkeria SDK)。电池续航时间虽然没有达到macOS的宣称,但在重度使用下仍然保持在~4.5小时。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Asahi Linux 在 MacBook Air M2 上使用 Sway (lawrence.lu) 6 点赞 by andsoitis 2 小时前 | 隐藏 | 过去 | 收藏 | 1 条评论 gsora 5 分钟前 [–] 把 swaybar 放在刘海后方是个好主意!回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

2024-12-01

I bought a MacBook Air M2. As of writing, it’s very affordable with the 16 GB RAM, 256 GB SSD, 13.6” model available for $750. As of writing, also Asahi Linux doesn’t support anything newer than M2.

buy on amazon

FIGURE 1 Pic of my laptop.

EXIF data
Camera
FUJIFILM GFX100S
Lens
GF55mmF1.7 R WR
Aperture
f/1.7
Shutter
1/42 s
ISO
ISO 400
Software
Digital Camera GFX100S Ver2.12
Date
Download

I had previously used:

  • 2011-2015: MacBook Air 13.3” with Intel Core i5 1.8 GHz, 8 GB of RAM, and 256 GB SSD (aftermarket upgrade from OWC). I installed Arch Linux on it with the i3 window manager.
  • 2014-2018: Dell XPS 13 Developer Edition. I used the Ubuntu 14.04 that came with it with the i3 window manager.
  • 2018-2024: Lenovo Thinkpad X1 Carbon Gen 6 with Intel Core i7 8640U, 16 GB of RAM, and 1 TB SSD. I installed Arch Linux on it with Sway.

On the Asahi Linux there’s a one liner which you can paste into the Terminal. It worked very well. The only complaint is that it seemed to take hours to copy root.img and boot.img over at 150 KB/s.

Since I intended to run it with the Sway Window Manager, and storage space is precious, I installed Fedora minimal.

I connected to wifi with

nmcli device wifi list
nmcli device wifi connect 'my_ssid' password 'mypassword'

and then I installed a bunch of packages I use, such as:

sudo dnf install @sway-desktop-environment fish alacritty rofi ruff rclone pavucontrol-qt i3status mako pass syncthing maim xdg-user-dirs firefox rustup openssl-devel ncdu fd-find neovim

Then, I cloned my personal dotfile git repo and ran setup.sh. Of course, my configs weren’t meant for the MacBook, so I had to make some changes (which I’ve pushed to the dotfiles).

By default, the whole row containing the notch is disabled, leading to a large-bezels look which I personally don’t like. There has got to be a way to use that screen real estate nicely!

I re-enabled that part of the screen with

grubby --args=apple_dcp.show_notch=1 --update-kernel=ALL

Then, I put the Sway bar on the top to make a seamless appearance where the left and right side are used for useful information but the middle part is all black. By experimentation I found that the notch is 56px tall.

bar {
    position top
    status_command i3status
    modifier $mod
    tray_output primary
    # the height of the m2 macbook air's notch???
    height 56
    colors {
        background #000000
        statusline #cfcfd9
        separator #000000
        # border background text
        focused_workspace #0c0c0c #413459 #cfcfd9
        active_workspace #0c0c0c #413459 #cfcfd9
        inactive_workspace #0c0c0c #0c0c0c #cfcfd9
        urgent_workspace #2f343a #ff3300 #ffffff
    }
}

The full i3status shows a lot of information which might get occluded by the notch, and it doesn’t work with the MacBook battery levels by default, so I had to update the config:

general {
        colors = true
        interval = 5
}

order += "wireless _first_"
order += "ethernet _first_"
order += "battery 0"
order += "tztime local"

wireless _first_ {
        format_up = "W: (%quality at %essid) %ip"
        format_down = "W: down"
}

ethernet _first_ {
        format_up = "E: %ip (%speed)"
        format_down = "E: down"
}

battery 0 {
        format = "%status %percentage"
        hide_seconds = true
        path = /sys/class/power_supply/macsmc-battery/uevent
}

tztime local {
        format = "%Y-%m-%d %H:%M:%S"
}

I usually don’t like having the bar on the top (as with macOS), since you won’t be able to move your mouse cursor to the top edge to, say, click on tabs. Despite being mostly keyboard-driven, clicking on browser tabs with the mouse is something I still do often.

To fix that, I prevented the mouse cursor from entering the bar on the top, with

# use swaymsg -t get_inputs for the touchpad's identifier
input 1452:849:Apple_MTP_multi-touch map_to_region 0 56 2560 1608

I am very impressed with how smooth and problem-free Asahi Linux is. It is incredibly responsive and feels even smoother than my Arch Linux desktop with a 16 core AMD Ryzen 7945HX and 64GB of RAM.

The touchpad in particular is stunningly good and just as good as native macOS. The mouse cursor movement and two finger scroll with inertia just feel incredibly natural, much better than my old Thinkpad X1 Carbon.

One of the main reasons for getting the laptop was to use it for line scan photography. I was able to install the Alkeria SDK for ARM64 without any issues, even though it came as a deb file instead of an rpm. I didn’t manage to get alien to work properly (something about the architecture arm64 not matching Fedora’s convention of calling it aarch64?) so I just used bsdtar to extract the contents into the filesystem root, yolo!!! The M2 compiles my code super fast!

With high screen brightness and compiling lots of code, my battery went down from 100% to 60% after about 4.5 hours of use — not as good as the 15 hours of battery life on macOS but still pretty respectable.

联系我们 contact @ memedata.com