logo
Published on

Linux技巧笔记

Authors
  • avatar
    Name
    realth000
    Twitter

前言

好记性不如烂笔头,长期更新Linux使用日常中遇到的犄角旮旯的东西。

这里可能很多条目都写明了具体发行版,实际上很通用,不必拘泥于版本。

Arch Wayland配置Fcitx5中文输入法

折腾了很久,各自帖子都看了,好久才完全折腾好。

Fcitx5本身没什么问题,问题在于Wayland不完善,以及各自软件使用的技术差异很大,需要各自配置。

基础配置

安装fcitx (AUR):

fcitx5 5.0.23-1
fcitx5-breeze 2.0.0-1
fcitx5-chinese-addons 5.0.17-1
fcitx5-configtool 5.0.17-1
fcitx5-gtk 5.0.23-1
fcitx5-pinyin-sougou 20210320-1
fcitx5-pinyin-zhwiki 1:0.2.4.20230329-1
fcitx5-qt 5.0.17-1

系统环境变量,写入到/etc/security/pam_env.conf

#
# What I wanted was the REMOTEHOST variable set, purely for selfish
# reasons, and AGM didn't want it added to the SimpleApps login
# program (which is where I added the patch). So, my first concern is
# that variable, from there there are numerous others that might/would
# be useful to be set: NNTPSERVER, LESS, PATH, PAGER, MANPAGER .....
#
# Of course, these are a different kind of variable than REMOTEHOST in
# that they are things that are likely to be configured by
# administrators rather than set by logging in, how to treat them both
# in the same config file?
#
# Here is my idea:
#
# Each line starts with the variable name, there are then two possible
# options for each variable DEFAULT and OVERRIDE.
# DEFAULT allows an administrator to set the value of the
# variable  to some default value, if none is supplied then the empty
# string is assumed. The OVERRIDE option tells pam_env that it should
# enter in its value (overriding the default value) if there is one
# to use. OVERRIDE is not used, "" is assumed and no override will be
# done. # # VARIABLE   [DEFAULT=[value]]  [OVERRIDE=[value]]
#
# (Possibly non-existent) environment variables may be used in values
# using the ${string} syntax and (possibly non-existent) PAM_ITEMs may
# be used in values using the @{string} syntax. Both the $ and @
# characters can be backslash escaped to be used as literal values
# values can be delimited with "", escaped " not supported.
# Note that many environment variables that you would like to use
# may not be set by the time the module is called.
# For example, HOME is used below several times, but
# many PAM applications don't make it available by the time you need it.
#
#
# First, some special variables
#
# Set the REMOTEHOST variable for any hosts that are remote, default
# to "localhost" rather than not being set at all
#REMOTEHOST	DEFAULT=localhost OVERRIDE=@{PAM_RHOST}
#
# Set the DISPLAY variable if it seems reasonable
#DISPLAY		DEFAULT=${REMOTEHOST}:0.0 OVERRIDE=${DISPLAY}
#
#
#  Now some simple variables
#
#PAGER		DEFAULT=less
#MANPAGER	DEFAULT=less
#LESS		DEFAULT="M q e h15 z23 b80"
#NNTPSERVER	DEFAULT=localhost
#PATH		DEFAULT=${HOME}/bin:/usr/local/bin:/bin\
#:/usr/bin:/usr/local/bin/X11:/usr/bin/X11
#
# silly examples of escaped variables, just to show how they work.
#
#DOLLAR		DEFAULT=\$
#DOLLARDOLLAR	DEFAULT=	OVERRIDE=\$${DOLLAR}
#DOLLARPLUS	DEFAULT=\${REMOTEHOST}${REMOTEHOST}
#ATSIGN		DEFAULT=""	OVERRIDE=\@
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#
#
# http_proxy=http://127.0.0.1:7890/
# https_proxy=http://127.0.0.1:7890/
# ftp_proxy=http://127.0.0.1:7890/
# HTTP_PROXY=http://127.0.0.1:7890/
# HTTPS_PROXY=http://127.0.0.1:7890/
# FTP_PROXY=http://127.0.0.1:7890/
# XMODIFIRES=@im=fcitx
# QT_IM_MODULE=fcitx
# GTK_IM_MODULE=fcitx
# SDL_IM_MODULE=fcitx

#GTK_IM_MODULE DEFAULT=fcitx
#QT_IM_MODULE  DEFAULT=fcitx
#XMODIFIERS    DEFAULT=\@im=fcitx
#SDL_IM_MODULE DEFAULT=fcitx
# Wayland compatibility
QT_QPA_PLATFORM         DEFAULT=wayland
CLUTTER_BACKEND         DEFAULT=wayland
SDL_VIDEODRIVER         DEFAULT=wayland
MOZ_ENABLE_WAYLAND      DEFAULT=1
MOZ_WEBRENDER           DEFAULT=1
XDG_SESSION_TYPE        DEFAULT=wayland
XDG_CURRENT_DESKTOP     DEFAULT=sway

# QT-related theming
QT_QPA_PLATFORMTHEME    DEFAULT=qt5ct

# FCITX input-related
#GLFW_IM_MODULE         DEFAULT=ibus
GLFW_IM_MODULE          DEFAULT=fcitx
GTK_IM_MODULE           DEFAULT=fcitx
INPUT_METHOD            DEFAULT=fcitx
XMODIFIERS              DEFAULT=@im=fcitx
IMSETTINGS_MODULE       DEFAULT=fcitx
QT_IM_MODULE            DEFAULT=fcitx
SDL_IM_MODULE           DEFAULT=fcitx
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#
#

浏览器

浏览器推荐使用Firefox,不需要做额外更改就可以使用Fcitx5输入中文。

chrome需要在启动中加参数--gtk-version=4,并且存在输入法候选框不跟着光标的问题,此外114版本的chrome加上如上flag后会在启动时崩溃。

Intellij全家桶

配置过基础环境变量后基本可以使用,但是会有候选框不跟随光标的问题,需要更换ide的java runtime

  1. RikudouPatrickstar/JetBrainsRuntime-for-Linux-x64下载,并解压。
  2. idea中按下Ctrl + Shift + \\,在弹出的对话框中选择“操作”,输入runtime,更换runtime。

设置java runtime

Fcitx5配置

默认配置有些地方不好用,需要改

输入中文标点

默认情况下,即使在输入中文时,打出来的标点符号也是英文的。

按下Ctrl + .切换到全角标点(中文标点)。

切换中英文

默认是Ctrl + Space,建议再加一个shift切换中英文。不然中文模式下想输入一点英文还要按两个键。

配置 -> 全局选项 -> 快捷键 -> 切换/禁用输入法 项。

输入中文时上屏一些英文单词

参考地址

输入中文时,按下Shift + Enter可以把当前这点英文上屏。

Debian12同时开启多张网卡

/etc/network/interfaces中添加配置,自动连接并设置为DHCP。

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback
auto enp0s3
iface enp0s3 inet dhcp
auto enp0s8
iface enp0s8 inet dhcp

grub设置默认timeout

前几天发生了个小插曲,想在办公本上把DE换成wayland,结果DM不支持导致进不去,并且grub也没开(timeout=0),这就奇怪了,我记得我之前已经设置过timeout了啊,原来是每次升级内核在重新生成grub.cfg时timeout被重置了。

默认timeout在/etc/default/grub,把GRUB_TIMEOUT=0值改掉即可。

设置主题和图标主题

之前多是用图形界面的配置来设置主题,现在用arch + hyprland需要从终端设置。

其实也简单:

gsettings set org.gnome.desktop.interface gtk-theme <theme name>
gsettings set org.gnome.desktop.interface icon-theme <icon theme name>

其中主题放在/usr/share/themes,图标放在/usr/share/icons,名字就是文件夹的名字。

另外推荐主题Qogir-dark和图标主题ePapirus-Dark,后者包含一个工具用来改变主题:

# -C后是文件夹图标颜色,-u代表刷新缓存,-t后跟papirus主题名
papirus-folders -C darkcyan -u -t ePapirus-Dark

项目地址:

Flatpak编译时配置cargo的rsproxy

最近开始玩gtk-rs,这一套和flatpak亲(绑)和(定),有一套仓库模板gtk-rs-template

基本是 rust + mason.

开发环境的话可以选择gnome的builder,也可以选择vs code + flatpak extension

clion暂时没有flatpak支持,暂时没琢磨怎么用,intellij-rust比rust-analyzer强很多,vsc扩展的github上已经有人提了移植到intellij的issue,暂时没动静,如果能在clion里用上就好了。

跑题了,构建的时候会在download crates的地方卡住,肯定要配置代理了。这里有两种思路:

  1. 直接配置flatpak的http代理,这个网上的方法好像没效果,或者说对于构建这一步来说没效果。
  2. 配置cargo的rsproxy代理,但是网上没有找到任何有关flatpak build rust app cargo proxy的信息,这块玩的国人不多吧。

绕了一个大圈,最后发现解决方法很简单:

rsproxy只能写在toml配置文件里,这个配置文件一般在cargo home的config里,这个其实是个全局的配置文件,对所有项目都适用。

而如果想为某个项目单独配置rsproxy,把相应的配置写到工程目录里的.cargo/config里即可,例如:

[source.crates-io]
# To use sparse index, change 'rsproxy' to 'rsproxy-sparse'
replace-with = 'rsproxy'

[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"

[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"

[net]
git-fetch-with-cli = true

emm,心疼硬盘,rust本来就是硬盘消耗大户,这flatpak还搞隔离环境,玩得开心就好。

另外:都2023年了怎么还在用*.in这种反人类的东西啊,rust-analyzer和intellij-rust都不认识写进去的配置定义,红一片,做成环境变量别的配置不好吗