2025年1月17日 星期五

Xfce4 編輯 menu

安裝
apt install -y menulibre

使用方式
right-click on applications
properties
edit menu

PHP proc_open 摘要

 <?php
  $cmd = "sqlite3 1.db ";
  $interactive_cmd = "insert into a (a1,a2) values('中文','許');";
  $descriptorspec = array(
    0 => array("pipe", "r"),  // stdin
    1 => array("pipe", "w"),  // stdout
    2 => array("pipe", "w")   // stderr ?? instead of a file
  );

  $stdout = "";
  $stderr = "";

  $process = proc_open($cmd, $descriptorspec, $pipes, NULL);

  if (is_resource($process)) {
    fwrite($pipes[0], $interactive_cmd . PHP_EOL);
    fclose($pipes[0]);

    while($s= fgets($pipes[1], 1024)) $stdout .= $s;  // read from the pipe
    fclose($pipes[1]);

    // stderr optional:
    while($s= fgets($pipes[2], 1024)) $stderr .= $s;
    fclose($pipes[2]);
  }

  echo "stdout: $stdout \nstderr: $stderr\n";
?>


Debian 12 限制掛載 usb flash 為唯讀

 編輯 /etc/udisks2/mount_options.conf 加入

[defaults]
defaults=ro
allow=exec,noexec,nodev,nosuid,atime,noatime,nodiratime,ro,sync,dirsync,noload

重新啟動服務
systemctl restart udisks2

參考
https://storaged.org/doc/udisks2-api/latest/mount_options.html

Debian 12 限制用戶登入終端機

編輯 /etc/pam.d/login 加入
account required /lib/security/pam_access.so

編輯 /etc/security/access.conf 加入
-:ALL EXCEPT root:tty1 tty2 tty3 tty4 tty5 tty6

2025年1月10日 星期五

Debian 12 使用 IBus 輸入法

安裝
apt install -y ibus-table
apt install -y ibus-chewing ibus-zhuyin ibus-table-easy ibus-table-easy-big

相關目錄
/usr/share/ibus-table/tables/
/usr/share/ibus-table/icons/

相關指令
ibus-table-createdb
ibus-setup
ibus restart

im-config  #apt install -y zenity

Windows 11 WSL 中文輸入 fcitx5

安裝
sudo apt install fcitx5 fcitx5-* # 全部Fcitx5支援的輸入法
sudo apt install fcitx5-chinese-addons fcitx5-chewing  # 只安裝新酷音注音
sudo apt install fcitx5-table-easy-large fcitx5-chinese-addons #只安裝輕鬆
sudo apt install fcitx5-frontend-gtk2 fcitx5-frontend-gtk3 fcitx5-frontend-gtk4 fcitx5-frontend-qt5 fcitx5-frontend-qt6

執行 
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export DefaultIMModule=fcitx
fcitx-autostart &>/dev/null

相關設定
im-config
fcitx5-configtool

export WAYLAND_DISPLAY='wayland-0' DISPLAY=':0'

Debian 12 ibus 安裝嘸蝦米

sudo apt install ibus-table

git clone https://github.com/daineseh/liu_ibus_table
cd liu_ibus_table
sudo ibus-table-createdb -s liu_ibus_table.txt -n liu.db
sudo cp liu.db /usr/share/ibus-table/tables/

sudo cp liu.png /usr/share/ibus-table/icons/

debain 12 自動更新

安裝
sudo apt update && apt upgrade
sudo apt install unattended-upgrades apt-listchanges -y
sudo systemctl enable unattended-upgrades
sudo systemctl start unattended-upgrades

編輯設定檔
/etc/apt/apt.conf.d/50unattended-upgrades

自動執行設定
dpkg-reconfigure unattended-upgrades
dpkg-reconfigure -f noninteractive unattended-upgrades
相關設定檔 /etc/apt/apt.conf.d/20auto-upgrades

測試
unattended-upgrades --dry-run --debug

參考文件
https://wiki.debian.org/UnattendedUpgrades

VNC X window screen locks: "Authentification error"

loginctl list-sessions
loginctl unlock-session SESSION-ID