To swap command and alt buttons on Apple Magic Keyboard (and not globally) add the following line in /etc/modprobe.d/hid_apple.conf:options hid_apple swap_opt_cmd=1`