在 Linux 下使用 Office 365

在 Windows 上用习惯了微软全家桶,切到 Linux 就没指望了,又不能说装个 Windows 虚拟机就为了用 Office 365,那只好尝试找找替代品了。

首先是 Outlook,包含了学校账户的 Exchange ActiveSync,个人 Outlook 邮箱还有日程功能。在 Linux 上比较常见的邮件客户端是 Mozilla Thunderbird,通过插件配置可以最低限度地支持 Outlook 提供的一些服务。

  • owl for exchange 提供 Exchange ActiveSync 的邮件支持
  • lightning 提供 Outlook 日历的基础功能支持
  • tbsync + provider for exchange activesync 提供到 Office 365 账户的日历同步功能
  • provider for google calendar 为 lightning 提供到 Google Calendar 的同步功能

有了这些插件以后,就可以依次添加自己的账户开始同步了。不能说多好用,勉强能用吧。

然后是 Microsoft To-Do,这个有好事者开发了一个跨平台的版本:klaussinani/ao。通过 snap 就可以安装。

还有 OneNote,这个似乎除了网页版就没有什么比较好用的版本,不过也有好事者用 Electron 做了一个本地网页客户端:patrikx3/onenote。还算能用,也是通过 snap 安装。

OneDrive 的同步,也有好事者写了 Linux 上可用的版本:skilion/onedrive。这个要写一下正确的安装流程,我装的时候差点就把 OneDrive 里面的文件全部删掉了,幸好有回收站。

对于 Ubuntu 18.04,安装流程是这样的:

sudo apt install libcurl4-openssl-dev
sudo apt install libsqlite3-dev

# Ubuntu 18
sudo snap install --classic dmd && sudo snap install --classic dub

git clone https://github.com/skilion/onedrive.git
cd onedrive
make
sudo make install

注意,在运行之前,一定是在运行之前,自行在 ~/.config 下创建配置文件目录,以 ~/.config/onedrive 为例,如果需要同步多个账户则应使用不同的目录名称:

mkdir -p ~/.config/onedrive
cp ./config ~/.config/onedrive/config
nano ~/.config/onedrive/config

config 文件结构类似这样:

# Directory where the files will be synced
sync_dir = "~/OneDrive"
# Skip files and directories that match this pattern
skip_file = ".*|~*"

标记了默认的同步路径为 ~/OneDrive,由于在首次运行 onedrive 的时候默认就是授权,因此如果要更改同步目录的话,在这里要先在配置文件里面写好。然后运行 onedrive –confdir=”~/.config/onedrive” 开始进行授权操作,这样就会在 sync_dir 处创建对应的文件夹,然后开始下载。

如果要自动同步,在 make install 之后,在 /usr/lib/systemd/user 下已经被创建了一个 onedrive.service 文件,类似这样:

[Unit]
Description=OneDrive Free Client
Documentation=https://github.com/skilion/onedrive

[Service]
ExecStart=/usr/local/bin/onedrive -m
Restart=no

[Install]
WantedBy=default.target

如果想要同步多个账户的话,把 ExecStart 改成类似于 onedrive -m –confdir=”~/.config/onedrivePersonal” 这样带有配置文件目录的形式。之后:

systemctl --user enable onedrive
systemctl --user start onedrive

就可以启动服务自动运行了。

如果不想使用 User Service,希望在系统启动时运行,则在 /etc/systemd/system 下创建 onedrive.service,写入类似于:

[Unit]
Description=OneDrive Free Client
Documentation=https://github.com/skilion/onedrive

[Service]
ExecStart=/usr/bin/sudo -u <user> /usr/local/bin/onedrive -m --confdir="/home/<user>/.config/onedrive"
Restart=always

[Install]
WantedBy=default.target

之后:

systemctl enable onedrive
systemctl start onedrive

切记,不能在授权完成之后,复制 config 文件并更改 sync_dir,然后直接用 -m 参数运行 onedrive,这样会使得该程序认为本地有全部删除的更改,会直接删掉 OneDrive 上所有文件。所以一定要先写配置文件再授权。

最后记录一下添加 SMB 打印机的过程,Linux 通过 CUPS 管理打印机,但是图形界面的管理未必好用,可以尝试用 localhost:631 来管理,注意 cups-2.2.7 在 Linux 版 Chrome 上有 bug,会出现 unauthorized error,这个需要升级到 2.2.8 或者使用 firefox。具体配置可以看 Arch Wiki

在 Linux 下使用 Office 365》有2个想法

  1. Alex

    FYI the ‘skilion’ github repo is unmaintained appears to have been abandoned and contains many other issues that have not been fixed. It contains defects that put you at risk of data loss and corruption. If you wish to use the latest code which contains numerous fixes and enhancements you need clone & build from here: https://github.com/abraunegg/onedrive

    All of your instructions above will redirect people to a bad code & as per your experience, lead to data loss.

    回复

回复 Alex 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注