4/17/2024

Ubuntu 22.04, Cinnamon Desktop missing slack icons in the system tray

To solve this problem:

 sudo apt purge indicator-application

4/14/2024

How to set Windows 11 to hibernate automatically (hibernate after)

Just to be clear, Windows has two low-power modes:

Sleep - All non-essential activities and drivers are stopped and the processor goes into power-conservation mode

Hibernate - The current system state is stored to hard drive, and the system powers off

Sleep is enabled OOTB and can be controlled by control panel.

You can enable hibernate from the advanced power settings in control panel.

In Windows 10, you can set the timeout so that after sleeping for a certain duration, the PC automatically hibernates to go to deep power saving.

Windows 11 seems to be missing the UI feature to set that time out and by default it's set to a very long time (like 16 hours)

Here's how to enable hibernate and set the timeouts by the command line.


Open an elevated command prompt (run as administrator)

Enable hibernate:  powercfg /HIBERNATE ON

Query the current hibernate idle settings: powercfg /Q

Look for a section that looks like:


Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)

  GUID Alias: SCHEME_BALANCED 

  Subgroup GUID: 238c9fa8-0aad-41ed-83f4-97be242c8f20  (Sleep) 


    GUID Alias: SUB_SLEEP 


    Power Setting GUID: 9d7815a6-7ee4-497e-8888-515a05f02364  (Hibernate after) 


      GUID Alias: HIBERNATEIDLE 


      Minimum Possible Setting: 0x00000000 


      Maximum Possible Setting: 0xffffffff 


      Possible Settings increment: 0x00000001 


      Possible Settings units: Seconds 


    Current AC Power Setting Index: 0x00000000 


    Current DC Power Setting Index: 0x00000e10


0x00000e10 = 3600 seconds


To set the DC power (battery power) timeout: powercfg /x  hibernate-timeout-dc 60

This will set it to 60 min or 3600 seconds or 0x00000e10 seconds

You can even make it work when on AC power (plugged in): powercfg /x  hibernate-timeout-ac 60 

4/04/2024

Migrate a dual-boot (Windows 11 + Ubuntu 22.04) Surface Pro 6 to a new Surface Pro 9

Both Surface Pro 6 and Surface Pro 9 have 520 TB SSD hard drives.

Goal: Use Clonezilla to copy/image 3 Ubuntu partitions of the old Surface Pro 6 (/dev/nvme0n1p4, /dev/nvme0n1p5, /dev/nvme0n1p7) to the new Surface Pro 9 system.

The Surface Pro 9 Windows system was set up with the Windows 11 that came with the new computer. I only wanted to clone the Ubuntu 22.04 to avoid setting up the development environment again.

1. On old Surface Pro 6:

    Clonezilla:

  • Press Power + Volume Down button to start from the USB. Choose large VGA + to RAM option.
  • Selected /dev/nvme0n1p4, /dev/nvme0n1p5, /dev/nvme0n1p7 to clone and saved to a 2TB HDD.
2. On new Surface Pro 9:

  • Windows 11: EaseUS Partition Master Free tool to shrink the SSD to allocate 200500 MB free space for Ubuntu.
  • Power+VolumeDown boot from the Boot Repair Disk. Use GParted tool to create 3 partitions: /dev/nvme0n1p5 (ex4, 1024 MB), /dev/nvme0n1p6 (ex4), /dev/nvme0n1p7 (linux-swap, 20480 MB).
  • Edit the saved backup/image on the 2TB HDD. Change all files names: *p4* -> *p5*, *p5* -> *p6* and the parts file content to: nvme0n1p5, nvme0n1p6, nvme0n1p7

 

Clonezilla:

  • Start from USB
  • Follow the instructions of Clonezilla to restore 3 partitions.

 

Boot Repair Disk:

  • Boot from the USB 
  • Follow the instructions to repair the boot

  • Windows 11: Start PowerShell in Admin mode and run: bcdedit /set "{bootmgr}" path \EFI\ubuntu\grubx64.efi
  • Reboot and the Grub selection menu should show. Choose Ubuntu as the option to start the system.
  • The Ubuntu system won't start. Reboot and enter the recovery mode. In the recovery mode:
    • sudo apt remove lightdm
    • nmtui to connect to the WIF
    • sudo apt install gdm3
    • sudo reboot
  • The dualboot should be set up successfully now.

 

10/17/2023

Ubuntu 22.04 setup

 1. 网易云音乐

sudo apt remove libproxy-tools

然后用:

~/bin$ cat m.sh 
#!/bin/sh
# HERE="$(dirname "$(readlink -f "${0}")")"
HERE=/opt/netease/netease-cloud-music
export LD_LIBRARY_PATH="${HERE}"/libs
export QT_PLUGIN_PATH="${HERE}"/plugins
export QT_QPA_PLATFORM_PLUGIN_PATH="${HERE}"/plugins/platforms
# 手动指定运行库
cd /lib/x86_64-linux-gnu/
export GDK_SCALE=2
export QT_SCALE_FACTOR=2
export ELM_SCALE=2
/opt/netease/netease-cloud-music/netease-cloud-music $@


2. Cisco Anyconnect VPN

 不能乱用其他版本的libgio-2.0.so.0,不然会出现错误:you're missing the required libraries for the authentication method you requested


3. 微信

https://github.com/zq1997/deepin-wine/issues/310

解决HDPI问题:WINEPREFIX=~/.deepinwine/Deepin-WeChat /usr/bin/deepin-wine6-stable winecfg (Graphics分辨率修改到192)


12/25/2022

科学上网: Setup Trojan on AWS 翻墙

首先推荐商业订阅版:https://egjplmujirj2tbj9wuzy.wgetcloud.org/, 价格还可以接受

一定要自己setup就继续往下看:

https://github.com/trojan-gfw/trojan

安装方式搜索:科学上网 Trojan

首先安装:sudo apt install trojan

需要有一个domain name,通过https://certbot.eff.org/申请一个免费的cert

https://github.com/trojan-gfw/trojan/wiki/Binary-&-Package-Distributions

server端配置:

{

    "run_type": "server",

    "local_addr": "0.0.0.0",

    "local_port": 1443,

    "remote_addr": "qq.com",

    "remote_port": 443,

    "password": [

        "password1",

        "password2"

    ],

    "log_level": 1,

    "ssl": {

        "cert": "/etc/letsencrypt/live/yougood.ai/fullchain.pem",

        "key": "/etc/letsencrypt/live/yougood.ai/privkey.pem",

        "key_password": "",

        "cipher": "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384",

        "cipher_tls13": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",

        "prefer_server_cipher": true,

        "alpn": [

            "http/1.1"

        ],

        "alpn_port_override": {

            "h2": 81

        },

        "reuse_session": true,

        "session_ticket": false,

        "session_timeout": 600,

        "plain_http_response": "",

        "curves": "",

        "dhparam": ""

    },

    "tcp": {

        "prefer_ipv4": false,

        "no_delay": true,

        "keep_alive": true,

        "reuse_port": false,

        "fast_open": false,

        "fast_open_qlen": 20

    },

    "mysql": {

        "enabled": false,

        "server_addr": "127.0.0.1",

        "server_port": 3306,

        "database": "trojan",

        "username": "trojan",

        "password": "",

        "key": "",

        "cert": "",

        "ca": ""

    }

}


https://github.com/Loyalsoldier/clash-rules

规则编辑 | Clash for Windows (lbyczf.com)

我的常用配置:One Drive/应用/clash/1671973573180.yml

使用TUN模式:

dns:

  enable: true

  enhanced-mode: fake-ip

  nameserver:

    - 8.8.8.8

    - 8.8.4.4

  fallback: []

  fake-ip-filter:

    - +.stun.*.*

    - +.stun.*.*.*

    - +.stun.*.*.*.*

    - +.stun.*.*.*.*.*

    - "*.n.n.srv.nintendo.net"

    - +.stun.playstation.net

    - xbox.*.*.microsoft.com

    - "*.*.xboxlive.com"

    - "*.msftncsi.com"

    - "*.msftconnecttest.com"

    - WORKGROUP

tun:

  enable: true

  stack: system

  auto-route: true

  auto-detect-interface: true

  dns-hijack:

    - any:53


用TUN模式要把文件C:\Program Files\Clash.for.Windows-0.20.11-win\resources\static\files\win\x64\clash-win64.exe加到防火墙 允许的应用(搜索允许。。。)


(不推荐使用System Proxy模式,如果用了的话:) bypass setting (在Clash app settings里面设置,不是配置文件!!)

12/17/2022

ssh disconnects after idle

 Change server /etc/ssh/sshd_config

ServerAliveInterval 15

ServerAliveCountMax 3


Setup OpenVPN server on AWS 翻墙

GFW可以很容易检测到OpenVPN,封锁端口,一般只能用一天就不能用了。所以这种办法还是不要用了。应该使用trojan:GitHub - trojan-gfw/trojan: An unidentifiable mechanism that helps you bypass GFW.

1. Find a region that's close to you. Launch an EC2 machine, search for an OpenVPN image from the market place. Choose the Bring Your Own License option

2. Mostly follow this site: How to create a free VPN server on AWS | by Israel Aminu | Towards Data Science

3. After you can login to the Admin page, make the following changes:

1) In the VPN Settings, Routing, Should VPN clients have access to private subnets (non-public networks on the server side)? -> Yes using Routing

2) DNS Settings, Have clients use specific DNS servers. Yes, Primary DNS Server->8.8.8.8, Secondary DNS Server->8.8.4.4

3) Change Server Network Settings, VPN Server | Hostname or IP Address: -> public IP address of the server 

 

4. Unlimited hack: ✔️ Remove restrictions from OpenVPN Access Server | RuCore.NET - English Version or https://drive.google.com/file/d/1Wp3h1VBJUY7eaLuUtMewbP1iS-tEGNbf/view?usp=sharing