X240 Ubuntu18.04安装流水帐

U盘安装

使用Startup Disk Creator和下载好的iso文件创建启动U盘 (在win7下官网建议的刻录软件是Rufus, https://rufus.akeo.ie/)

 

Nautilus无法使用type-ahead功能

18.04的默认文件浏览器Nautilus彻底删除了type-ahead功能, 在浏览中输入按键会自动变成全系统搜索, 这个对日常使用造成了很大的不便. 在Nautilus的项目主页上有很长的讨论 https://gitlab.gnome.org/GNOME/nautilus/issues/244https://gitlab.gnome.org/GNOME/nautilus/issues/466https://gitlab.gnome.org/GNOME/nautilus/issues/590https://gitlab.gnome.org/GNOME/nautilus/issues/923https://gitlab.gnome.org/GNOME/nautilus/issues/1157 

Update 2018-06-18: 可以通过一个第三方的ppa替换成带type-ahead功能的Nautilus:

sudo add-apt-repository ppa:lubomir-brindza/nautilus-typeahead
sudo apt update
sudo apt dist-upgrade

如果要恢复回自带Nautilus的话:

sudo apt install ppa-purge
sudo ppa-purge ppa:lubomir-brindza/nautilus-typeahead

 

禁用指点杆的中键粘贴 Disabling Trackpoint middle-mouse button paste

默认的中键功能是: 点击立即释放是粘贴(作用在浏览器中是新标签页打开链接或关闭窗口), 点击并移动指点杆是滚动页面. 但是因为X240触摸板的失败设计, 左键和中键没有明显的区分, 在工作中经常造成误击中键, 而且经常由于食指和拇指配合不好导致页面滚动变成了粘贴. 这在写代码的过程中尤为恼人.

在18.04中, xinput的输出已经和16.04不一样, 原先的设置 xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Timeout" 1 已经无效. 通过gnom-tweak-tool 设置禁用鼠标中键粘贴对这个也不起作用. 有一篇文章说安装xserver-xorg-input-synaptics替代xserver-xorg-input-libinput, 但是尝试无效(也许我的方法不对..). 各种尝试得到的结果是, 只能通过set-button-map 将中键禁用. 参考 https://wiki.ubuntu.com/X/Config/Input

# 查看xinput设备列表
milton@milton-X240:~$ xinput list
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                  id=11    [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                       id=12    [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
    ↳ Power Button                                id=6    [slave  keyboard (3)]
    ↳ Video Bus                                   id=7    [slave  keyboard (3)]
    ↳ Sleep Button                                id=8    [slave  keyboard (3)]
    ↳ Integrated Camera: Integrated C             id=9    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard                id=10    [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                      id=13    [slave  keyboard (3)]

# 对应指点杆的设备是id=12
milton@milton-X240:~$ xinput list-props 12
Device 'TPPS/2 IBM TrackPoint':
    Device Enabled (142):    1
    Coordinate Transformation Matrix (144):    1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    libinput Natural Scrolling Enabled (285):    0
    libinput Natural Scrolling Enabled Default (286):    0
    libinput Scroll Methods Available (289):    0, 0, 1
    libinput Scroll Method Enabled (290):    0, 0, 1
    libinput Scroll Method Enabled Default (291):    0, 0, 1
    libinput Button Scrolling Button (303):    2
    libinput Button Scrolling Button Default (304):    2
    libinput Middle Emulation Enabled (295):    0
    libinput Middle Emulation Enabled Default (296):    0
    libinput Accel Speed (297):    -0.690647
    libinput Accel Speed Default (298):    0.000000
    libinput Accel Profiles Available (305):    1, 1
    libinput Accel Profile Enabled (306):    1, 0
    libinput Accel Profile Enabled Default (307):    1, 0
    libinput Left Handed Enabled (299):    0
    libinput Left Handed Enabled Default (300):    0
    libinput Send Events Modes Available (262):    1, 0
    libinput Send Events Mode Enabled (263):    0, 0
    libinput Send Events Mode Enabled Default (264):    0, 0
    Device Node (265):    "/dev/input/event6"
    Device Product ID (266):    2, 10
    libinput Drag Lock Buttons (301):    <no items>
    libinput Horizontal Scroll Enabled (302):    1

# 查看按键, 其中1, 2, 3分别对应的 左, 中, 右键
milton@milton-X240:~$ xinput get-button-map 12
1 0 3 4 5 6 7 

# 将中键禁用 
milton@milton-X240:~$ xinput set-button-map 12 1 0 3 4 5 6 7

这个并不能永久保存, 需要写入bashrc等以便于每次启动桌面时自动生效. 如果安装了xserver-xorg-input-synaptics, 会导致中键又生效...
终于可以愉快地中键翻屏, 不用担心中途不小心粘贴什么了.

指点杆加速度

在gnom-tweak-tool里可以选择三种profile: adaptive, normal, flat: The profile decides the general method of pointer acceleration. libinput currently supports two profiles: "adaptive" and "flat". The aptive profile is the default profile for all devices and takes the current speed of the device into account when deciding on acceleration. The flat profile is simply a constant factor applied to all device deltas, regardless of the speed of motion. https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
选adaptive感觉比较适合1080p分辨率下的桌面. 有一定的加速度, 又不会太灵敏.

安装WPS

直接安装deb包会报错

$ sudo dpkg -i wps-office_10.1.0.5672~a21_amd64.deb
Selecting previously unselected package wps-office.
(Reading database ... 118097 files and directories currently installed.)
Preparing to unpack wps-office_10.1.0.5672~a21_amd64.deb ...
Unpacking wps-office (10.1.0.5672~a21) ...
dpkg: dependency problems prevent configuration of wps-office:
 wps-office depends on libpng12-0; however:
  Package libpng12-0 is not installed.

dpkg: error processing package wps-office (--install):
 dependency problems - leaving unconfigured
Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Errors were encountered while processing:
 wps-office

18.04本身不带这个版本的libpng, 要通过第三方包安装

ibpng12-0下载: http://archive.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.27-2+lenny5_amd64.deb
安装libpng12-0:

sudo dpkg -i libpng12-0_1.2.27-2+lenny5_amd64.deb

之后再安装就成功了

Update 2018-08-21: WPS has released wps-office_10.1.0.6634_amd64 on Jun 5, libpng is not needed now.

Update 2019-10-11: WPS has released wps-office_11.1, same installation steps.

安装PAC Manager

ubuntu自带的pac版本是4.5.5.8, 比sourceforge上的版本还高... 所以直接通过ubuntu软件中心安装了

安装Redis 4.0.9

先安装gcc,  sudo apt-get install gcc, 然后解压编译, 编译出现错误  error: jemalloc/jemalloc.h: No such file or directory

可以通过强制使用libc的malloc进行编译 Selecting a non-default memory allocator when building Redis is done by setting  the `MALLOC` environment variable. Redis is compiled and linked against libc  malloc by default, with the exception of jemalloc being the default on Linux  systems. This default was picked because jemalloc has proven to have fewer  fragmentation problems than libc malloc.  To force compiling against libc malloc, use:  
    % make MALLOC=libc 
To compile against jemalloc on Mac OS X systems, use: 
    % make MALLOC=jemalloc

 

要运行make test需要安装 tcl

sudo make
sudo make test
# 安装到/opt/redis/redis-4.0.9/bin下, 然后再到/usr/bin去建好软链
sudo make PREFIX=/opt/redis/redis-4.0.9 install

 

配置

复制源代码目录下自带的conf模板 /usr/src/redis-4.0.9/redis.conf 到 /opt/redis/redis-4.0.9/conf, 需要编辑的变量

port 6039
daemonize yes
pidfile /var/run/redis_6039.pid
logfile "/var/redis/log/redislog"
databases 8
dir /var/redis/data
requirepass foobard

服务init.d脚本, 可以在源码的utils目录下找到一个 redis_init_script 文件, 按下面的格式修改

#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          redis
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $network $time
# Should-Stop:       $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/ Stop Redis Server daemon
# Description:       This service script facilitates startup and shutdown of
#                    redis daemon
### END INIT INFO
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

REDISPORT=6039
EXEC=/opt/redis/latest/bin/redis-server
CLIEXEC=/opt/redis/latest/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/opt/redis/latest/conf/${REDISPORT}.conf"
SECURE=foobard

case "$1" in
    start)
        if [ -f $PIDFILE ]
        then
                echo "$PIDFILE exists, process is already running or crashed"
        else
                echo "Starting Redis server..."
                $EXEC $CONF
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $CLIEXEC -p $REDISPORT -a $SECURE shutdown
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

将redis加入service, 添加完/etc/init.d/redis后, 还是不能用sudo service redis start来启动的, 需要先通过systemctl enable 命令来添加

$ sudo service redis start
Failed to start redis.service: Unit redis.service not found.
$ sudo systemctl enable redis
redis.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable redis

之后就能用sudo service redis start/stop来控制redis服务了.

如果需要禁止开机启动, 也可以通过systemctl

sudo systemctl disable mysql
sudo systemctl enable redis
sudo systemctl disable redis

查看系统中的服务, 会显示服务是否开机启动(enable or disable)

sudo systemctl list-unit-files

 

安装unar

避免解压包含中文文件名的zip时产生乱码

sudo apt-get install unar

安装MySQL

(安装过程略)

Update 2018-11-27: 通过apt安装的mysql, 其配置文件位于/etc/mysql/, 其中的/etc/mysql/mysql.conf.d/mysqld.cnf 是服务端的配置信息 (虽然在/etc/mysql/mysql.cnf中两个includedir前面都有 ! 号, 不确定这是表示引用还是不引用).

Update 2020-11-07: 使用apt安装的mysql-server(mysql 8.0), 安装过程中不提示输入密码, 需要在安装后, 执行 sudo mysql_secure_installation , 会提示设置root口令, 口令强度及是否允许远程登录等一系列安全设置. 但是执行后似乎并未生效, 使用sudo mysql -uroot依然可以直接登录, 而普通用户mysql -uroot -p依然无法登录, 随后还是通过在mysql命令行修改mysql.user表下root用户的plugin以及修改root口令解决问题

-- 
UPDATE user SET plugin='caching_sha2_password' WHERE User='root';
-- 
ALTER user 'root'@'localhost' identified by 'Newpass.2020';

Update 2018-06-14: 在安装了mysql-8.0之后, 因为client与原先的mysql5.7不兼容, 不得已还是把8.0卸载了重新安装5.7, 其中碰到的一些问题:

1. 重新安装5.7后, service mysql start一直失败, 后来发现是原先的数据目录还存在, 5.7用原先的数据启动导致失败. 将/var/lib/mysql目录删除后, 再卸载&安装5.7, 就可以正常启动了
2. root登录口令. 因为安装过程中并未提示输入口令, 所以采用了 mysqld_safe --skip-grant-tables 的方式启动后再登录命令行, 修改口令, 但是很奇怪的是一直不生效, 命令行连接后依然出现 ERROR 1698 (28000): Access denied for user 'root'@'localhost' 错误, 但是用sudo mysql -uroot 却不需要口令就可以登录, 后来google发现是这个原因:

The reason is that recent Ubuntu installation (maybe others also), mysql is using by default the UNIX auth_socket plugin. Basically means that: db_users using it, will be "auth" by the system user credentias. You can see if your root user is set up like this by doing the following:

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> SELECT User, Host, plugin FROM mysql.user;

+------------------+-----------------------+
| User             | plugin                |
+------------------+-----------------------+
| root             | auth_socket           |
| mysql.sys        | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+

As you can see in the query, the root user is using the auth_socket plugin
There are 2 ways to solve this:
  You can set the root user to use the mysql_native_password plugin
  You can create a new db_user with you system_user (recommended)
Option 1:

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

Option 2: (replace YOUR_SYSTEM_USER with the username you have)

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> CREATE USER 'YOUR_SYSTEM_USER'@'localhost' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_SYSTEM_USER'@'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='YOUR_SYSTEM_USER';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

Remember that if you use option #2 you'll have to connect to mysql as your system username (mysql -u YOUR_SYSTEM_USER)

安装sublime text3

参考 http://www.cnblogs.com/milton/p/4215116.html
下载当前最新的deb https://download.sublimetext.com/files/sublime-text_build-3170_amd64.deb   
修复fcitx无法输入中文的问题: https://github.com/lyfeyaj/sublime-text-imfix  git clone到本地后, 执行一下./sublime-imfix就完成修复了.

 

安装 gnome-tweak-tool 调整字体

sudo apt install gnome-tweak-tool

安装 chrome-gnome-shell 因为需要用到 unite-shell extension

sudo apt-get install chrome-gnome-shell

安装 unite-shell extension

访问网址 https://github.com/hardpixel/unite-shell . 根据页面的安装说明, 在releases里面下载最新的zip包, 解压缩至 ~/.local/share/gnome-shell/extensions
注意: 1)如果路径不存在则创建路径 2)解压完后, 重启桌面即可在 gnome-tweak-tool 的extensions里看到unite. 这样安装不需要安装浏览器扩展. 3)如果开启后发现fctix消失, 可以重启一下ubuntu.

安装完后, 主要有两点改进: 1)将时钟移到了右侧, 2)最大化窗口时, 将窗口标题栏与ubuntu桌面顶栏合并, 节约空间

Update 2019-10-11: unite-shell-v33 doesn't work with 18.04, in tweak extensions panel it says "error loading extension", v18 works.

安装SS-libev

直接通过apt install 安装, ss-local会安装到/usr/bin/

 

安装截图软件Shutter

sudo apt install shutter

之后安装libgoo-canvas以启用编辑功能, 下载三个deb

https://launchpad.net/ubuntu/+archive/primary/+files/libgoocanvas-common_1.0.0-1_all.deb
https://launchpad.net/ubuntu/+archive/primary/+files/libgoocanvas3_1.0.0-1_amd64.deb
https://launchpad.net/ubuntu/+archive/primary/+files/libgoo-canvas-perl_0.06-2ubuntu3_amd64.deb

依次安装, 最后提示依赖问题用 sudo apt install -f修复

关闭上盖后禁止休眠

通过命令行修改 /etc/systemd/logind.conf, 将 HandleLidSwitch的值修改为ignore, 然后重启systemd-logind: sudo service system-logind restart

也可以通过Gnome Tweak Tool修改, 在power栏下有设置项.

电池阈值管理

需要将电池设置为 40%开始充电, 70%停止充电以最大限度延长电池使用寿命

需要apt install tlp, acpi-call-dkms 这两个软件, 用tlp setcharge [下限] [上限] [电池编号]设置阈值, 然后用 tlp-stat -b 查看

$ sudo tlp setcharge 50 80 BAT0
Setting temporary charge thresholds for BAT0:
  stop  = 80
  start = 50
$ sudo tlp-stat -b
--- TLP 1.1 --------------------------------------------

+++ ThinkPad Battery Features
tp-smapi   = inactive (unsupported hardware)
tpacpi-bat = active

+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/class/power_supply/BAT0/manufacturer                   = SONY
/sys/class/power_supply/BAT0/model_name                     = 45N1111
/sys/class/power_supply/BAT0/cycle_count                    = (not supported)
/sys/class/power_supply/BAT0/energy_full_design             =  23200 [mWh]
/sys/class/power_supply/BAT0/energy_full                    =  20650 [mWh]
/sys/class/power_supply/BAT0/energy_now                     =  14560 [mWh]
/sys/class/power_supply/BAT0/power_now                      =   4376 [mW]
/sys/class/power_supply/BAT0/status                         = Discharging

tpacpi-bat.BAT0.startThreshold                              =     50 [%]
tpacpi-bat.BAT0.stopThreshold                               =     80 [%]
tpacpi-bat.BAT0.forceDischarge                              =      0

Charge                                                      =   70.5 [%]
Capacity                                                    =   89.0 [%]

  

posted on 2018-05-04 13:57  Milton  阅读(699)  评论(0编辑  收藏  举报

导航