export USERNAME="newuser"
export PASSWD="password"
useradd -m $USERNAME -s /bin/bash -g users
echo -e "$PASSWD\n$PASSWD" | passwd $USERNAME
Kin的筆記本
2024年3月16日
不用手動介入,在Linux下建立新User並設定密碼
2024年3月9日
最近在用的Archlinux桌面環境
留個套件名字
下次換新電腦還可以裝
顯示管理 greetd + regreet
視窗管理 hyprland
啟動器 rofi
輸入法 fcitx5
終端機 qterminal + bash
檔案管理 dolphin
2023年3月18日
2022年12月24日
Firefox 108 滑鼠游標消失的問題
最近Firefox 升級到 108 之後發現
自訂的游標圖示會顯示錯誤,甚至有時後會直接消失
檢查Log發現是Firefox無法讀取到我的自訂游標
firefox-bin[2959]: Unable to load hand2 from the cursor theme
firefox-bin[2959]: Unable to load left_ptr from the cursor theme
firefox-bin[2959]: Unable to load xterm from the cursor theme
而且是放在~/.icons下的游標才會有這個問題
所以目前有一個Workaround方式就是將目前使用的游標放到
mv ~/.icons/* /usr/share/icons/
目前已經有人發了 Issue 給 Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1802877
su + systemctl = Failed to connect to bus: No medium found
最近想用 su - user 對修改 user 的 systemd Unit 的時候發現
systemctl --user
的所有操作都會回報
Failed to connect to bus: No medium found
後來找到了這篇文章
只要將 su - user
改為使用machinectl shell user@.host
就可以正常使用 systemctl --user 了
從 Caddy2 對 Syncthing 以子路徑進行反向代理
有些服務 的 web UI 需要執行在網頁的根路徑或特定路徑上
例如 transmission 就需要路徑 /transmission/web/
而 Syncthing 就必須是 / 才能正確打開Web UI
如果直接反向代理的話就會發現有許多圖片或restful api會找不到
我們需要在代理時將多餘的子路徑去除才會正確找到檔案
在Caddy2下可以這麼做
http://myhost.org {
handle_path /syncthing/* {
reverse_proxy http://localhost:8384 {
header_up Host {http.reverse_proxy.upstream.hostport}
}
}
}
其中handle_path就會在轉送要求時將 syncthing/ 這個前綴移除
這樣有需要的話還可以在同一個host上代理多個syncthing
例如
http://myhost.org {
handle_path /syncthing/* {
reverse_proxy http://localhost:8384 {
header_up Host {http.reverse_proxy.upstream.hostport}
}
}
handle_path /syncthing2/* {
reverse_proxy http://localhost:8385 {
header_up Host {http.reverse_proxy.upstream.hostport}
}
}
}
2016年3月5日
Android WebView 的 JavaScript 與 Java 交互
webView.getSettings().setJavaScriptEnabled(true);
要讓其中可以存取 Java 中的功能,就要建立一個可以讓 JavaScript 存取的 Interface
class JsObject { @JavascriptInterface public void alert(String ss) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("TestAlert"); builder.setMessage(ss); builder.show(); } }
有 @JavascriptInterface 標記的 Method 才會在JavaScript中被允許使用
然後將這個 class 加入WebView,其中 "myjs" 可以自訂為任意文字
webView.addJavascriptInterface(new JsObject(), "myjs");
最後在網頁中這樣呼叫就可以了
<script> window.myjs.alert("GG"); </script>