【打造家庭服务器系列02】笔记本安装Ubuntu后的一些配置

一、如何开启和关闭蓝牙

方式一

# 安装蓝牙包
apt install bluez

# 查看蓝牙信息
hciconfig -a

# 关闭蓝牙
hciconfig hci0 down

方式二

# 查看蓝牙开启状态,关闭蓝牙状态
systemctl status bluetooth

二、查看电池电量

使用upower命令

upower --dump | grep --color=never -E "state|to\ full|to\ empty|percentage"
    state:               discharging    # 充电状态, discharging 表示未充电
    time to empty:       21.8 hours     # 应该是预计使用时长吧,我猜测
    percentage:          89%    		# 电池剩余电量

但是我们不可能每次查看电池电量都输入这么一串命令,我们可以给这个命令设置一个别名,到时候直接输入别名就能查看

vim ~/.bashrc
# 在末尾加入,power-now 就是设置的别名,可以自定义名称
alias power-now='upower --dump | grep --color=never -E "state|to\ full|to\ empty|percentage"'

# 刷新bash
bash
root@rion-mi:~# power-now
    state:               discharging
    time to empty:       21.8 hours
    percentage:          87%

三、关闭屏幕休眠

当我们把屏幕合上时,电脑会处于休眠状态,此时ssh无法连接。
我们需要关闭屏幕休眠。
修改配置文件

cat /etc/systemd/logind.conf
......
# 笔记本电脑使用电池供电时
HandleLidSwitch=ignore
# 笔记本使用电源供电
HandleLidSwitchExternalPower=ignore
# 笔记本连接到拓展坞时
HandleLidSwitchDocked=ignore
......

配置参数说明
ignore(无操作),
poweroff(关闭系统并切断电源),
reboot(重新启动),
halt(关闭系统但不切断电源),
kexec(调用内核"kexec"函数),
suspend(休眠到内存),
hibernate(休眠到硬盘),
hybrid-sleep(同时休眠到内存与硬盘),
suspend-then-hibernate(先休眠到内存超时后再休眠到硬盘),
lock(锁屏)

重启服务

systemctl restart systemd-logind

参考地址: https://blog.csdn.net/qq_31635851/article/details/124627990

注:

这一篇内容主要是对笔记本安装Ubuntu后遇到问题的记录,后续会持续更新。