顯示具有 ubuntu 標籤的文章。 顯示所有文章
顯示具有 ubuntu 標籤的文章。 顯示所有文章

2026-04-29

ubuntu開啟DNS over TLS (DoT)

 修改 /etc/systemd/resolved.conf:
[Resolve]
DNS=8.8.8.8#dns.google 1.1.1.1#cloudflare-dns.com
DNSSEC=yes #檢查簽章
DNSOverTLS=no
DNSStubListener=yes #開啟本機dns服務

重啟resolve服務:
sudo systemctl restart systemd-resolved.service

查看是否正常運作:
sudo resolvectl status

檢查/etc/resolv.conf,看是否正確指向本機127.0.0.53:
nameserver 127.0.0.53

2026-03-27

使用bottles安裝line

1. 執行以下指令,讓bottles能利用fcitx5輸入 (fictx5套件要有裝gtk及qt模組):

flatpak override --user --filesystem=xdg-download --filesystem=xdg-data/applications --talk-name=org.fcitx.Fcitx5 --talk-name=org.freedesktop.portal.Fcitx com.usebottles.bottles

檢查:
flatpak override --user --show com.usebottles.bottles

或看bottles override設定檔是否有設定成功:
~/.local/share/flatpak/overrides/com.usebottles.bottles
===========
[Context]
filesystems=xdg-download;xdg-data/applications;

[Session Bus Policy]
org.freedesktop.portal.Fcitx=talk
org.fcitx.Fcitx5=talk
===========

2.在bottles建立一個執行環境,取名LINE,並做以下設定:

  • 作業系統:設為win10
  • 安裝附加元件:cjkfonts, vcredist2022, d3dcompiler_47(亦可先不裝,有問題再來裝)
  • 設定該bottle(LINE)的環境變數,以便能使用fcitx5輸入:
    GTK_IM_MODULE=fcitx
    QT_IM_MODULE=fcitx
    XMODIFIERS=@im=fcitx
  • 執行器選擇kron4ek(如果line安裝時會卡住,那麼就先改為使用soda,安裝完再改回)
  • 如果lIne裡面開圖或開影片會閃退,那麼關掉DXVK及VKD3D試試
3. 對bottles開啟的line其穩定度不要有太大的期待,沒事就當掉是家常便飯。

2025-12-19

Ubuntu/Linux Mint 的Cisco VPN (vpnc) 無法連線,出現認證雜湊為MD5不安全

若Cisco VPN Server是舊型的,認證(authentication)的雜湊算法只支援MD5,無法升級到SHA2,那麼在較新版Cisco VPN Client(vpnc)連線時可能會出現要你加入 --enable-weak-authentication 的參數(連線時用journalctl -f可看到),

但如果你用的是NetworkManager的network-manager-vpnc 套件,而不是直接用vpnc指令去連線,那麼也無法直接對指令加參數(因GUI介面也無該選項可勾選),即便修改 /etc/vpnc/default.conf也沒用(因為network-manager-vpnc不會讀取該檔),或修改 /etc/netplan/ 下面NetworkManager的vpnc設定檔也無法加入參數(因為沒有像extra args之類的參數能加),只能靠寫一個vpnc wrapper的shell script來解決:

cd /usr/sbin
sudo mv vpnc vpnc.orig
sudo vi vpnc
==========================
!/bin/bash

# Wrapper for vpnc to enable weak auth for legacy Cisco VPNs
# Original vpnc: /usr/sbin/vpnc.orig

if [[ "$*" == *"--nolaunch" ]]; then
    # Skip if it's a check from Network Manager
    exec /usr/sbin/vpnc.orig "$@"
else
    exec /usr/sbin/vpnc.orig --enable-weak-authentication "$@"
fi
===========================
sudo chmod +x vpnc

這樣在連線Cisco VPN時,就會強制加入該 --enable-weak-authentication 參數了。

2025-12-15

Linux Ubuntu 利用滑鼠側鍵

#安裝工具
 sudo apt install xbindkeys xdotool

#點擊滑鼠側鍵,通常是button 8 或 button 9
xev | grep button

#產生設定檔
xbindkeys --defaults > ~/.xbindkeysrc

#編輯.xbindkeysrc,範例如下:

#button 8 模擬中鍵
"xte 'mouseclick 2'"
b:8 + Release

#button 9 輸出字串
"xdotool type 123456"
b:9 + Release

#button 9 模擬 ctrl+c
"xdotool key ctrl+c"
b:9 + Release

#button  8 模擬 ctrl+v
"xdotool key ctrl+v"
b:8 + Release

#重啟 xbindkeys 載入設定,記得將xbindkeys加到開機啟動
killall xbindkeys && xbindkeys

2025-12-07

Nvidia 顯卡在 Linux Mint / Ubuntu 的 ucsi_ccg_init failed 問題

 dmesg -H -l err 出現以下訊息:

nvidia-gpu 0000:01:00.3: i2c timeout error e0000000
ucsi_ccg 1-0008: i2c_transfer failed -110
ucsi_ccg 1-0008: ucsi_ccg_init failed - -110

這是因為NVIDIA 驅動想透過 I2C 去跟 Type-C 控制晶片(CCG)溝通,但怎麼叫都沒反應,導致一直噴錯誤到 dmesg,這通常 不會影響顯示卡正常運作,只是 log 很醜、偶爾會吵醒系統(影響待機功耗),如果你根本不用 Type-C 充電(或卡上也沒vlink / usb-c DP),可以直接禁掉ucsi_cgg模組/aux i2c/i2c bus:

#方法一,直接關掉ucsi_ccg模組
echo "blacklist ucsi_ccg" | sudo tee /etc/modprobe.d/blacklist-ucsi_ccg.conf

#方法二,關掉aux i2c
echo 'options nvidia NVreg_EnableGpuAuxI2c=0' | sudo tee /etc/modprobe.d/nvidia-fix-i2c-timeout.conf

#方法三,關掉特定 bus
dmesg | grep -i ucsi_ccg #找出哪條噴錯,通常是i2c-10 或 i2c-8
echo 'options nvidia NVreg_RegistryDwords="RMDisableAuxBus=0x10"' | sudo tee /etc/modprobe.d/nvidia-fix-i2c-timeout.conf 

#ramfs update
sudo update-initramfs -u


2023-09-18

Ubuntu/Linux Mint在 Macbook 13" 2014 的無線網卡/麥克風/風扇/攝影機設定

0.無線網卡:
因為broadcom的網卡driver不是開源而是專有的,所以用以下指令自動安裝(如nvidia driver也是):
sudo ubuntu-drivers autoinstall

1.修正line-in麥克風:
找到 mbp 2014 13"的機型識別碼:MacBookPro11,1

再找到 driver 為 Cirrus Logic CS4208 = mbp11

修改  /etc/modprobe.d/alsa-base.conf ,新增:
options snd-hda-intel model=mbp11

2.修正風扇不正常問題:
sudo apt install mbpfan
sudo systemctl status mbpfan

避免風扇時不時狂轉,修改/etc/mbpfan.conf:
min_fan1_speed = 2000
max_fan1_speed = 3500
...
polling_interval = 5

3.修正facetime webcam:

直接使用該ppa:
https://launchpad.net/~greg-whiteley/+archive/ubuntu/facetimehd

sudo add-apt-repository ppa:greg-whiteley/facetimehd
sudo apt install facetime-dkms facetime-firmware
sudo dkms autoinstall (有更換kernel的話)
sudo reboot

===== 以下僅適用於舊的dkms及舊的kernel =======

如果是iSight鏡頭(通常是2005~2010的macbook,如果不是請略過):
下載文章附件的AppleUSBVideoSupport,解壓縮:
https://www.linux.org/threads/installing-linux-on-an-imac.26009/
sudo apt install isight-firmware-tools
指向剛剛的AppleUSBVideoSupport檔案

安裝facetime camera firmware:
sudo apt install curl xzcat cpio git
git clone https://github.com/patjak/facetimehd-firmware.git
cd facetimehd-firmware
make
sudo make install

安裝facetime camera driver:
git clone https://github.com/patjak/bcwc_pcie.git
apt install debhelper dkms
mkdir /usr/src/facetimehd-0.1
cd bcwc_pcie
cp -r * /usr/src/facetimehd-0.1/
cd /usr/src/facetimehd-0.1/
make clean
dkms add -m facetimehd -v 0.1
dkms build -m facetimehd -v 0.1
dkms mkdsc -m facetimehd -v 0.1 --source-only
dkms mkdeb -m facetimehd -v 0.1 --source-only
cp /var/lib/dkms/facetimehd/0.1/deb/facetimehd-dkms_0.1_all.deb /root/
rm -r /var/lib/dkms/facetimehd/
dpkg -i /root/facetimehd-dkms_0.1_all.deb

ref:
https://askubuntu.com/questions/1430547/webcam-not-working-in-ubuntu-22-04-on-macbook-air
https://github.com/patjak/facetimehd/wiki/Installation#get-started-on-debian
https://github.com/linux-on-mac
https://support.apple.com/zh-tw/HT201300
https://askubuntu.com/questions/984239/no-microphone-picked-up-on-ubuntu-16-04-on-macbook-pro
https://www.kernel.org/doc/html/latest/sound/hd-audio/models.html

2023-02-14

在macbook pro M1安裝Ubuntu 22.04

在macbook pro M1的UTM安裝Ubuntu arm版很簡單,照下列一步步安裝即可:
https://docs.getutm.app/guides/ubuntu/

官方的教學是安裝server版再安裝ubuntu-desktop,
若需要直接安裝有桌面的ubuntu arm版,可在下面下載:
https://cdimage.ubuntu.com/jammy/daily-live/current/

有個比較需要注意的是utm的模擬顯示卡,及x11跟wayland的問題,
在ubntu登入畫面點擊姓名,再點擊右下角的齒輪,
可選擇gdm3 session使用X11或wayland登入,但因utm的顯卡模擬有些還是有bug,
如顯卡模擬選項有gpu support的(如virtio-ramfb-gl),選擇x11或wayland登入時,可能造成某些軟體視窗打不開或一片黑,若遇到問題先不要選有gpu support的,選virtio-ramfb就好,這樣用x11就比較不會有問題(或有的用wayland沒問題,切換試試)。或更新utm看看能不能解決。

2023-02-12

RK987在Linux/Ubuntu下模擬成Apple鍵盤造成Function keys不正常的問題

 二年多前在淘寶買的RK987藍芽雙模鍵盤,在Linux/Ubuntu下的F1-F12總是會模擬成多媒體鍵(不管有無加上Fn),用lsusb指令查看,發現這鍵盤的vid:pid是05ac:024f,名稱是Apple Keyboard,才發現這鍵盤把自已假裝成Apple鍵盤了,這導致Linux會自動載入hid_apple驅動,但這鍵盤的F1-F12卻又無法正常使用。

解法是修改Fn的預設行為:

echo "options hid_apple fnmode=2" | sudo tee -a /etc/modprobe.d/hid_apple.conf 
sudo update-initramfs -u <for Ubntu/Debain>
sudo mkinitcpio -P <for Arch>

並將鍵盤模式用Fn+A切換成WIN模式。

下面解釋了Fn設為0,1,2的不同:

  1. 0 = disabled : Disable the 'fn' key. Pressing 'fn'+'F8' will behave like you only press 'F8'
  2. 1 = fkeyslast : Function keys are used as last key. Pressing 'F8' key will act as a special key. Pressing 'fn'+'F8' will behave like a F8.
  3. 2 = fkeysfirst : Function keys are used as first key. Pressing 'F8' key will behave like a F8. Pressing 'fn'+'F8' will act as special key (play/pause).

ref:
https://unix.stackexchange.com/questions/604791/keyboard-function-keys-always-trigger-media-shortcuts-regardless-of-whether-fn
https://unix.stackexchange.com/questions/121395/on-an-apple-keyboard-under-linux-how-do-i-make-the-function-keys-work-without-t
https://unix.stackexchange.com/a/672672

2023-01-18

酷比魔方GT BOOk 13(ALLDOCUBE i1305)安裝Linux Mint 22.1

 以下僅列幾個安裝linux mint/ubuntu時的注意事項:

1.由於購買時選的是無風扇的版本(有出帶風扇版本,但電池變小,風扇並沒搭配熱導管,就只是抽風而已沒啥用,而且還比較貴),因此買了相變導熱片PTM7950跟Laird導熱硅脂墊片2mm來改裝CPU散熱,實際可壓到15W沒問題。

2. bios關閉tpm跟secure boot,graphic的部份把數字都調到最大。修改 /etc/default/grub,加入:
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
#GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=3
GRUB_GFXMODE=1600x1200
GRUB_GFXPAYLOAD_LINUX=keep

3.網卡是realtek rtl8821ce,請不要用rtl8821ce-dkms的驅動,直接改用5.19以上的kernel即可,否則用dkms驅動非常之不穩且訊號也不太好,修改 /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf,將 wifi.powersave = 3 改為 wifi.powersave = 2 以關閉wifi省電避免掉線。

可用 iwconfig 查看 Power Management 是不是確定為off。

4.可用 https://github.com/georgewhewell/undervolt 調整 PL1 及 PL2 (參數為-p1, -p2)解TDP上限,可設為-p1 6 30 -p2 15 1,官方TL2到20W,只設到15W是怕被動散熱壓不住。
或用
https://slimbook.es/en/tutoriales/aplicaciones-slimbook/514-en-slimbook-intel-controller
但要修改 /home/<user>/.config/slimboookintelcontroller/slimbookintelcontroller.conf,加入:
n-5100 = /6@8/6@10/8@12/ 6/10/15 w

再修改 /usr/share/slimbookintelcontroller/src/utils.py,找到
patron = re.compile(r"[ ](\w\d)[-]([0-9]{4,5})(\w*)"),改為:

if cpu.find("Intel") != -1:
            #patron = re.compile(r"[ ](\w\d)[-]([0-9]{4,5})(\w*)")
            #version = patron.search(cpu).group(1)
            #number = patron.search(cpu).group(2)
            #line_suffix = patron.search(cpu).group(3)
            #model_cpu = version + "-" + number + line_suffix
            #return cpu, model_cpu, version, number, line_suffix
            return "Intel N5100", "N5100", "N", "5100", ""

省電控制也可使用 https://slimbook.es/en/tutoriales/aplicaciones-slimbook/520-slimbook-battery-4-application-to-optimize-your-laptop-s-battery
但因這台筆電的電池回傳資訊有缺少電池種類(technology),故要修改程式碼,打開
/usr/share/slimbookbattery/src/slimbookbatterypreferences.py
約539行(battery_data = {}),改為:

        battery_data = {'technology':'lithium-polymer',
                'time to empty':'6.0 hours',
                'time to full':'0.0 hours'}

這樣程式才能正確執行並儲存修改。

5.螢幕的亮度快捷鍵(Fn+F6/F7)無法作用,目前還沒找到解法,先暫時用工具列的電源圖示去調整,或者在系統設定的「鍵盤/快捷鍵鉏合/系統/硬體」裡自訂調整螢幕亮度的快捷鍵(我是設為win + F6/F7)。
可下載ICC描述檔校正螢幕顏色:
https://www.notebookcheck.net/uploads/tx_nbc2/VVX14P048M00.icm

6.觸控版(SYNA3602:00 0911:5288 Touchpad)可二三四多點觸控,可安裝
https://github.com/bulletmark/libinput-gestures
支援手勢。下邊有左中右鍵,滑的手感不太好。

7.安裝lutris時,官方文件是說要裝最新驅動:
https://github.com/lutris/docs/blob/master/InstallingDrivers.md#amd--intel
但實際上照這指令先加ppa再安裝可能會找到不對應的安裝包,因此指令中加PPA的部份先不要執行,等安裝完再加入PPA然後再更新。若不小心已先安裝,用「更新管理員/軟體來源/維護」的「降級外來軟體包」,把來源為kiask的包先降級為官方包=>移除kiask ppa=>重裝lutris=>安裝
sudo dpkg --add-architecture i386 && sudo apt update && sudo apt upgrade && sudo apt install libgl1-mesa-dri:i386 mesa-vulkan-drivers mesa-vulkan-drivers:i386

sudo add-apt-repository ppa:kisak/kisak-mesa & sudo apt update & sudo apt upgrade
特別注意的是kiask這個PPA有時會造成更新管理員出錯卡住,此時可執行「軟體來源」把這個ppa先拿掉再更新。

8.chromium的硬體加速一直無法搞定,不管怎麼修改環境變數為LIBVA_DRIVER_NAME=iHD,都一樣只吃i965_drv_video.so而不吃iHD_drv_video.so,可能chromium及i965驅動二者都有問題(UHD核顯太新嗎?),改使用firefox則妥妥的(https://wiki.archlinux.org/title/firefox)。
可安裝intel-gpu-tools,使用intel_gpu_top看是否有吃到gpu,並安裝enhanced-h264ify把VP8及AV1擋掉。
記得11代CPU(Jasper Lake)的UHD核顯要裝 intel-media-va-driver-non-free 及 i965-va-driver-shaders
支援的codec: https://www.intel.com/content/www/us/en/develop/documentation/media-capabilities-of-intel-hardware/top.html#media-capabilities-supported-by-intel-hardware_codecs-decode-support-for-11th-and-12th-generation-intel-core-processors
(但vainfo並沒顯示有支援av1跟vp8,可能是intel的驅動又沒有加了...)

9. mint 21 (ubuntu 22)的network manager可以直接加wireguard的vpn了,但非常難用,因為是以虛擬網卡的方式使用,還是改用令令列 wireguard 吧,或者用一些免費的gui:
https://github.com/UnnoTed/wireguird
https://github.com/Devsfy/wiregui
設定cisco vpn時,一直無法儲存,結果是tunnel interface name一定要設,以前是不用的,所以隨便打個1就行。
設定l2tp vpn時,一直無法連線成功,結果是PPP Settings裡的「允許下列驗證方法」,這裡面「千萬」不要取消任何的勾選,直接勾「使用點對點加密」及「允許可設定狀態加密」即可,讓程式自動去取消勾選。

10. fcitx5的可安裝以下DEB加入額外輸入法(嘸蝦米、倉頡等),不要用官方的:
https://github.com/duckfly-tw/fcitx5-extra-tables-deb/releases/tag/v1

2022-11-24

"libglib2.0-0:i386 相依於 zlib1g (>= 1:1.2.2)" 造成套件無法安裝問題

 dpkg: error processing package libglib2.0-0:i386 (--configure):

 dependency problems - leaving triggers unprocessed
================

dpkg: dependency problems prevent processing triggers for libglib2.0-0:i386:

 libglib2.0-0:i386 相依於 zlib1g (>= 1:1.2.2)﹔然而:

  zlib1g:i386 套件尚未設定。
================

dpkg: dependency problems prevent processing triggers for libglib2.0-0:i386:

 libglib2.0-0:i386 depends on zlib1g (>= 1:1.2.2); however:

  Package zlib1g:i386 is not configured yet.

================

解法:
dpkg --force depends -P libglib2.0-0:i386


ref:

https://github.com/pop-os/pop/issues/1276#issue-716376795

2022-04-16

ubuntu/mint下chromium啟用硬體加速+解決netflix無法觀看

在ubuntu/mint下要啟用chromium的硬體加速,必須是pathced過的版本,

可以用 https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta 
(包含Widevine,觀看netflix等有DRM保護的串流時需要)

或 https://github.com/Eloston/ungoogled-chromium#downloads 
(不包含Widevine)

先裝好對應各顯卡的VA-API driver,啟動chromium時加上以下參數:

chromium-browser --use-gl=desktop --enable-features=VaapiVideoDecoder --disable-features=UseChromeOSDirectVideoDecoder
(chromium 98開始需加上 --disable-features=UseChromeOSDirectVideoDecoder)

====2024.09更新(在128的版本實測有效):==========

https://ubuntuhandbook.org/index.php/2024/01/chromium-va-api-wayland/
https://debugpointnews.com/va-api-chromium-wayland/

chromium 121以後的版本,可以不用再找有va-api patched過的版本,直接使用以下參數開啟硬體加速:

On X11:
chromium-browser --enable-features=VaapiVideoDecodeLinuxGL --use-gl=angle --use-angle=gl --ozone-platform=x11

On Wayland:
chromium-browser --enable-features=VaapiVideoDecodeLinuxGL --use-gl=angle --use-angle=gl --ozone-platform=wayland

=====================================

用ungoogled-chromium又想加上Widevine DRM支援時,
可先下載對應版本的Chrome DEB安裝檔(stable, unstable),
解開後,把 ./opt/google/chrome/WidevineCdm 複製到
 /usr/lib/chromium/WidevineCd 或 ~/.local/lib/WidevineCdm

ref:
https://wiki.archlinux.org/title/Chromium#Hardware_video_acceleration
https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.html
https://ungoogled-software.github.io/ungoogled-chromium-wiki/faq#linux

2022-02-12

Acer SPIN 5 (SP513-55N, SP513-41N)安裝Ubuntu/Linux MINT Cinnamon 20.3

想要支援平版型筆電, MINT裝Cinnamon版本會友善一點,MATE/XFCE的支援度差一點,但後面會講解法。 

1.開機時按F2進BIOS,
在Main頁面按ctrl+s呼叫出隱藏選項,
將SATA Mode=> AHCI, trackpad => PS2(待會會再改回來),
在Security將TPM關閉,
在Boot頁面將Secure Boot關閉(要先在Security頁面設Supervisor Password才能改),
Boot priority order 設為要用來安裝Ubuntu/Mint的USB。

2.開始安裝Mint,安裝時個人是分成三個分割區:
EFI => 550mb (UEFI開機載入需要此分割區)
SWAP=> 5120mb
剩下的都格式化為ext4並 mount 給 /

3.裝完後,修改 /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nocrs" #加入pci=nocrs
GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved
GRUB_TIMEOUT=3

修改完執行 sudo update-grub

3.打開更新管理員執行更新,若是intel版本,AX210網卡需5.10+ kernel,AX200需5.1+ kernel。若是amd版本,附的應該是都MT7921聯發科網卡,需要5.12+ kernel,但我建議把聯發科卡換成intel網卡,就算弄到能上網一樣是真心爛(掉包降速斷線等)。

重開機,進BIOS把trackpad改回IC2,開機時在選單選擇用最新的kernel開機。

4.調整自動旋轉
= 若是Cinnamon =:
進 管理/顯示器/設定,選擇Hi-DPI啟用fractional scaling,fractional scaling選150%
安裝touchscreen旋轉時的xinput修正:
sudo apt-get install x11-touchscreen-calibrator

Cinnamon其中有一個"自動螢幕旋轉",請保持停用狀態,不然啟用的話,螢幕設定不知怎的都無法正常保存。

= 若是MATE/XFCE =:
桌面設定一樣改 Hi-DPI
sudo apt-get install x11-touchscreen-calibrator
xrandr --output eDP --scale 1.5x1.5
sudo apt install autorandr
autorandr --save work

不管哪個版本,自動旋轉請改用自動偵測script (https://askubuntu.com/a/1375561),可放到開機自動啟動:

sudo apt install iio-sensor-proxy inotify-tools

==================================
#!/bin/bash
# Auto rotate screen based on device orientation
monitor-sensor | \
while IFS= read -r str; do
  if [[ $str =~ orientation\ changed:\ (.*)$ ]]; then
    case "${BASH_REMATCH[1]}" in
    normal)
      xrandr --output eDP --rotate normal ;;
    bottom-up)
      xrandr --output eDP --rotate inverted ;;
    right-up)
      xrandr --output eDP --rotate right ;;
    left-up)
      xrandr --output eDP --rotate left ;;
    esac
  fi
done
=================================

5.調整firefox滑動及steam縮放,修改/etc/environment,加入:
MOZ_USE_XINPUT2=1 #firefox,並把firefox設定中的平滑捲動取消
# GDK_SCALE=2 #steam,不過建議在啟動steam時加在指令前面就好

6.調整java介面縮放,修改 ~/.profile,加入:
#java ui scale
export _JAVA_OPTIONS='-Dsun.java2d.uiScale.enabled=true  -Dsun.java2d.uiScale=2'

7.fcitx輸入文字時,候選字(preedit)視窗(fcitx-qimpanel)過小:

譬如用的是ubutnu-grey主題,那麼就修改:
sudo vi /usr/share/fcitx-qimpanel/skin/ubuntu-grey/fcitx_skin.conf

FontSize=36
CandFontSize=36

若是用default佈景,那就修改:
sudo vi /usr/share/fcitx/skin/default/fcitx_skin.conf

8.觸控板多指手勢支援:
X11(後面指令以X11為主):
https://github.com/bulletmark/libinput-gestures
https://gitlab.com/cunidev/gestures

sudo apt install python3 python3-pip python3-venv python3-gi python-gobject meson wmctrl xdotool libinput-tools gettext appstream-util

sudo gpasswd -a $USER input
git clone https://github.com/bulletmark/libinput-gestures.git
cd libinput-gestures
sudo make install (or sudo ./libinput-gestures-setup install)
cp /etc/libinput-gestures.conf ~/.config/libinput-gestures.conf
newgrp input
libinput-gestures-setup autostart start


git clone https://gitlab.com/cunidev/gestures
cd gestures
meson build --prefix=/usr
ninja -C build
sudo ninja -C build install

之後再執行gestures程式調整要的多指手勢

若display server是Wayland的話,可參考:
https://extensions.gnome.org/extension/1253/extended-gestures/

9.指紋辨識(Fingerprint Reader),因為我用不到,而且加入方式也挺麻煩,跳過。

10. 修正外接麥克風(內建麥克風正常)無法收音問題:
修改 /etc/modprobe.d/alsa-base.conf
加入:
options snd-hda-intel model=alc255-acer,dell-headset-multi
(https://askubuntu.com/a/1307107)

11.取消進入休眠HIBERNATE (按F1似乎還是會進待機SUSPEND,但不會叫不醒了,也行…)
修改 /etc/systemd/logind.conf:
HandleSuspendKey=ignore

ref:
https://sciactive.com/2020/12/04/how-to-install-ubuntu-on-acer-spin-5-sp513-54n-for-the-perfect-linux-2-in-1/
https://wiki.archlinux.org/title/HiDPI

2021-10-03

安裝 jetbrains projector 並以 user systemd 方式啟動

 安裝很簡單,直接參考github官方網站:
https://github.com/JetBrains/projector-installer

設定:
projector config list
projector config  edit <APP_NAME>

憑證:
若有用let's encrypt,可直接用如下指令安裝,記得憑證過期一樣要再重安裝一次
(APP_NAME可能為IntelliJ或DataGrip,可參照 ~/.projector/configs):

projector install-certificate <APP_NAME> --certificate /etc/letsencrypt/live/<change.to.your.site.com>/fullchain.pem --key /etc/letsencrypt/live/<change.to.your.site.com>/privkey.pem;

以下補充如何以user systemd的方式自啟動,這樣ide點擊exit或reload時就會重新啟動,也不用登入tty,以下以新增 IntelliJ IDEA為例:
mkdir -p ~/.config/systemd/user/
vi ~/.config/systemd/user/idea.service
加入:
======================
[Unit]
Description=Jetbrains Projector - IDEA

[Service]
Type=simple
#注意這裡要改為用 run.sh 執行
ExecStart=%h/.projector/configs/IntelliJ/run.sh
Restart=always

[Install]
WantedBy=default.target
======================
再執行(以一般使用者身份執行即可)
systemctl --user start idea
systemctl --user status idea
systemctl --user enable idea
#不用tty登入也可reboot時自啟動
loginctl enable-linger <username> 

ref:
https://youtrack.jetbrains.com/issue/PRJ-298
https://wiki.archlinux.org/title/systemd/User#Automatic_start-up_of_systemd_user_instances

2021-09-13

老筆電X61出現Possible missing firmware...訊息

由於 linux-firmware 套件缺少了i915晶片一些韌體,導致每次更新kernel就會出現下列訊息:

update-initramfs: Generating /boot/initrd.img-5.4.0-84-generic
W: Possible missing firmware /lib/firmware/i915/tgl_dmc_ver2_04.bin for module i915
W: Possible missing firmware /lib/firmware/i915/skl_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/bxt_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/glk_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/icl_guc_33.0.0.bin for module i915

缺韌體問題,就來這個網址下載這一包找找:
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/

果然找到,補到 /lib/firmware/i915/ 內就 ok 了!

ref:

老電腦舊電腦用 usb 或 live cd無法用一般模式開機時

今天準備用linux mint重灌一台AMD phenom quad的老電腦,結果無法用第一個選項正常開機(畫面會hang住),用第二個選項Compatibility mode倒是可以。後來發現按tab修改第一個選單的開機參數,改用nomodeset就可以了:

Replace "quiet splash" with "nomodeset" and press Enter to boot.

原因是現在graphic driver是直接做在kernel,這樣開機畫面會比較"漂亮",但對某些顯卡會無法正常使用,因此用nomodeset讓kernel以bios模式開機,直到進x window後再載入顯卡driver。

ref:
https://linuxmint-installation-guide.readthedocs.io/en/latest/boot_options.html#nomodeset-boot-option
https://askubuntu.com/questions/207175/what-does-nomodeset-do

2021-09-08

安裝jetbrains projector (Server Side)

 1.先依照github頁面步驟安裝projector
https://github.com/JetBrains/projector-installer#Installation

2.幫機器設定一個domain,並記得修改/etc/hostname

3.幫domain上letsencrypt憑證(不需要裝http server,因為我們需要的只是憑證而已),對外的80 port防火牆記得開。譬如OS是Ubuntu 20.04就照著選,伺服器選「None of the above」(cerbot已自帶http伺服器可自動認證)
https://certbot.eff.org/lets-encrypt/ubuntufocal-other

且certbot會產生systemd service及timer以後會自動更新憑證:
/etc/systemd/system/snap.cerbot.renew.service
/etc/systemd/system/snap.cerbot.renew.timer

4.安裝ide: projector install,再照著數字選擇你要安裝的ide跟版本,可以裝好幾個ide,所有ide安裝好後設定檔會放在 ~/.projector/configs/<config_name>
安裝時建議channel選tested,表示是有測試過能正常在projector運行的ide,否則裝非tested的有時會有些奇奇怪怪的問題。

5.設定ide:projector config edit,再照著數字選擇個別ide設定檔並設定(如ide要開在哪個port、要不要設token...等), 其中有一項會問你要不要設定ssl,選是的話會先使用jetbrains的自簽憑證。注意設定完port後也要記得開防火牆

6.幫projector裝上letsencrypt憑證,記住每裝一個ide就要重複一次上憑證的動作:
projector install-certificate <config_name> --certificate /etc/letsencrypt/live/your.domain.com.tw/cert.pem --key /etc/letsencrypt/live/your.domain.com.tw/privkey.pem

7.執行ide:projector run <config_name>
會出現連線的網址,如果有設定token,網址會帶token參數,把網址ip換成domain即可

8.可用(1)瀏覽器(2)projector client app (3)chrome的projector應用程式
等三種方式連線

9.若不想在server安裝projector, 也可以直接在本機的jetbrains ide裝projector plugin後成為本機伺服器,但每次有人從外部連線時需要點擊確認才能連線。

10.若多人共用同一台伺服器,建議修改 /et/clogin.defs 的umask值為 027,這樣使用者(ide)之後新建的檔案權限other(別人)就會是不可讀不可寫。

11.每次離開(exit)IDE, 那麼就等同於projector停止,需再project run <config_name>一次才能再啟動並連進ide,若要保持ide及projector運作,就不要在IDE點擊exit,或寫個 systemd 或用watchdog讓projector每次關閉後會再自動重啟。

2021-08-31

發現CPU及HD溫度太高,用cpulimit降低吃cpu程式的頻率,hdparm讓硬碟待命(standby, sleep)

最近發現在linux上用wine跑LINE非常吃CPU(近期發生,可能是這個原因,發生在wine6.8+以上,後來換回wine6.5就沒問題了),CPU溫度飆到快90度,於是用cpulimit降低wineserver這支程式的cpu頻率,先安裝cpulimit,並寫一支script執行,限制最高cpu最高吃到10%:

#/bin/bash
cpulimit --path /home/username/.PlayOnLinux/wine/linux-x86/6.13/bin/wineserver --limit 10

但有個缺點,打字輸入line變得非常慢還會掉字,開圖跟捲動也很慢,只好要跟人溝通時先關掉cpulimit,沒要輸入文字時再打開。

ref:
https://blog.gtwang.org/linux/limit-cpu-usage-of-a-process-in-linux-with-cpulimit-tool/
http://cpulimit.sourceforge.net/

另新裝了一顆從NSA的退下的3TB機械硬碟,查smart資訊發現溫度異常的高,我也不確定這樣正不正常,怕它提早掛掉,只好想辦法讓它平時待命以降溫。

1.方法一:修改 /etc/hdparm.conf,設定10分鐘後無存取待命,加入:

command_line {
hdparm -S 120 /dev/sdb
}

2.方法二:用systemd,新增或修改/etc/systemd/system/hdparm.service:

[Unit]
Description=hdparm sleep

[Service]
Type=oneshot
ExecStart=/usr/bin/hdparm -q -S 120 -y /dev/sdb

[Install]
WantedBy=multi-user.target

3.方法三:

直接叫出GUI磁碟工具,選擇要設定的硬碟,再按視窗右上角的「磁碟機設定值」,設定進入待命時間:


ref:
https://wiki.archlinux.org/title/hdparm#Putting_a_drive_to_sleep_directly_after_boot
https://askubuntu.com/questions/39760/how-can-i-control-hdd-spin-down-time
http://elmaz.blogspot.com/2009/08/ubuntu-linux-hdd-suspend.html

2021-08-29

Linux Mint的登入視窗(greeter)方向錯誤 & grub解析度(resolution)錯誤

 最近升級了辦公室電腦,把系統移到新電腦後,發現登入視窗的螢幕方向是左旋90度的(但登入後就變正常了),由於一直是使用雙螢幕但之前是沒這個問題的,即使重新設定設定中的「登入視窗」指定螢幕也是沒有用,於是只好直接修改/etc/lightdm/lightdm.conf,加入:

[Seat:*]
display-setup-script=xrandr -o right

強迫再右旋回來。

2022/02/22 updated:
原因是換了GTX 1660顯示卡後,/etc/X11/xorg.conf並末重新產生,導致還是舊的GT 710的設定,
可利用nvidia-xconfig或nvidia-settings重新產生xorg.conf:
https://wiki.archlinux.org/title/NVIDIA#Xorg_configuration

用nvidia-settings的話,點左邊X server Display Configuration,再點右下的Save to X Configuration File,但若是無法成功寫入的話,那麼就自行複製Preview的內容貼到xorg.conf。

GRUB的登入解析度也是變成640x480,因無法先載入nvidia驅動的關係,修改 /etc/default/grub,加入:

GRUB_GFXMODE=1024x768
GRUB_GFXPAYLOAD_LINUX=keep

再存檔執行 sudo update-grub 重開機。
(先執行sudo hwinfo --framebuffer或進grub執行videoinfo確定支援的framebuffer有哪些)

ref:
https://askubuntu.com/questions/408302/rotated-monitor-login-screen-needs-rotation
https://www.binarytides.com/ubuntu-fix-nvidia-graphics/
https://askubuntu.com/questions/54067/how-to-safely-change-grub2-screen-resolution
https://askubuntu.com/questions/217758/how-to-make-an-xorg-conf-file
https://zhuanlan.zhihu.com/p/33983810

2021-05-05

升級JDK 11.0.11後,無法正常使用TLS寄信

 ubuntu上面利用javax.mail寫的寄信程式,在系統自動升級jdk到 11.0.11 後,使用tls smtp寄信就失效了,經查是因為 jdk已禁用了 tls 1.0, tls 1.1,所以必須改強制使用 tls >= v1.2(很奇怪的點就是javax.mail握手時不會自動tls v1.2 or 1.3) ,當然你的mail server也要有支援 tls >= v1.2


            props.setProperty("mail.smtp.host", "your.smtp.server");

            props.setProperty("mail.smtp.auth", "true");

            props.setProperty("mail.smtp.port", "587");

            props.setProperty("mail.smtp.starttls.enable", "true");

            props.setProperty("mail.smtp.ssl.protocols", "TLSv1.2"); //強制tls v1.2

            Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {

                @Override

                protected PasswordAuthentication getPasswordAuthentication() {

                    return new PasswordAuthentication("username", "password");

              }

            });

2021-03-04

netbeans在ubuntu上不斷要求開啟GNOME Keyring或KWallet 解決方法

 根據官方說明,這是netbeans用來記憶ftp, git, svn...等密碼的方法,就如同 window的login-based encryption、Mac OS X的Keychain、Linux的GNOME Keyring或KWallet。

解法一:安裝kwalletmanager或 libgnome-keyring-dev(擇一),並輸入你的使用者密碼讓netbneas有keyring或kwallet的存取權,以後就不會再來煩你了。

解法二:在netbeans.conf的netbeans_default_options加入:
-J-Dnetbeans.keyring.no.master=true
這樣以後密碼會存放在記憶體,但netbeans關掉就密碼就會消失了。

ref:

http://wiki.netbeans.org/FaqMasterPasswordDialog
https://wiki.archlinux.org/index.php/Netbeans#Integrate_Netbeans_with_kwallet
https://stackoverflow.com/questions/8666670/how-to-make-the-netbeans-doesnt-ask-for-the-master-password
https://superuser.com/questions/416976/why-does-netbeans-ask-for-master-password-at-the-begining