2022年7月21日 星期四

Retrieve tag from Apple Music using mp3tag

Problems

Finding tags for ripped music files sometimes are pain because the source is quite difficult to find. Ever since Amazon forbids the free use to retrieve tag of mp3tag, Apple Music becomes a new source for tags.

Solutions

1. Download and install mp3tag
2. Install the Japanese UI language (optional), unzip, copy all content to %PROGRAMFILES%\Mp3tag\lang
3. Navigate to %appdata%\Mp3tag\data\sources\Mp3tag\data\sources, copy all the content of files to this directory
4. Restart mp3tag
5. Drag music files / directories to the table
6. Right click and find tag using the newly added sources

References

2022年6月21日 星期二

Configure chrome remote desktop in Ubuntu 20.04 (Updated June 2025)

Problems

Chrome remote desktop creates a new session for remote session, which is not suit my needs, like Windows's remote, I need to "resume" the current session of the original desktop.

Solutions

1. In the host Ubuntu machine, install chrome remote desktop, using the deb provided by Google making use of the command sudo dpkg -i chrome-remote-desktop_current_amd64.deb

2. In the host machine, install chrome remote desktop application, perform the remote host setup following the instructions until you see the remote device appeared in the remote list.

You should see status "Online" in the device list, if it does not,













  • There are cases where "Loaded: masked (Reason: Unit chrome-remote-desktop.service is masked.)" error occurs, if so, run sudo rm /lib/systemd/system/your_app.service  to remove the systemd service of the chrome-remote-desktop and reload the systemd daemon by running sudo systemctl daemon-reload. Re-check the status of the chrome-remote-desktop and active status should be achieved
3.  Modify the file /opt/google/chrome-remote-desktop/chrome-remote-desktop,  change variable FIRST_X_DISPLAY_NUMBER to the output value of the command echo $DISPLAY.

4. Apply the differences manually for the remaining changes mentioned here. Do not use the patch command to patch the file as it may cause failure.

5. Create Xsession file under the config profile of chrome remote desktop using the following command. echo "1" > ~/.config/chrome-remote-desktop/Xsession, where "1" is the $DISPLAY value output mentioned in step #3. (value may vary depending on devices)

6. Restart the chrome remote desktop daemon with sudo systemctl daemon-reload followed by sudo /etc/init.d/chrome-remote-desktop restart. Re-check the chrome remote desktop status by sudo systemctl status chrome-remote-desktop.


Appendix
1. This method does not support wayland, only support Xorg, make sure wayland support is disabled. Edit file /etc/gdm3/custom.conf, make sure WaylandEnable parameter is configured to false

2. When activating through chrome remote desktop UI is not working (e.g.: Unknown error), try using headless enable, navigate to the chrome remote desktop in the remote client, in the left hand side menu, choose "configure through SSH", copy the command provided

DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/0AdQt8qgifMrurEQn65gbwYJOA3VrpusSF64i8Fwxfl9Nn6uL7L2KLUdw75HXhpFqlfGG-w" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=$(hostname)

You may need to re-generate the key if the time is expired, copy and paste it to the remote host, follow the setup netvigation to complete the remote host setup

Updated: 4/6/2024

As of chrome remote desktop version v121+,

1. Download the patch file

2. Remove the first 4 lines of the patch file

3. Navigate to /opt/google/chrome-remote-desktop, apply the patch by "sudo patch -Np1 -i /path/to/use_existing_session.patch", update the FIRST_X_DISPLAY_NUMBER variable to the one output using "echo $DISPLAY", and also update value of ~/.config/chrome-remote-desktop/Xsession to the DISPLAY value

4. Update the XSession to disable wayland, set WaylandEnable to false, run "sudo systemctl restart gdm3" to take effect.

5. Re-login Ubuntu (re-configure the chrome remote desktop where possible) "DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/0AdLIrYeNopk9TMNaSyMPAXCr25kRpDPi5oUt9w7IJkC5ALTp75JlaKajanli3b3XQ_RDlw" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=$(hostname)"

Patch file backup


Updated: 30/6/2025

As of latest "Ubuntu chrome remote" current session solution, just follow the guide to apply the update of file "/opt/google/chrome-remote-desktop", following the instruction marked here , (backup as following)

rm ~/.config/chrome-remote-desktop/Xsession
echo $DISPLAY | tr -d ':' >> ~/.config/chrome-remote-desktop/Xsession && cd /opt/google/chrome-remote-desktop
sudo cp chrome-remote-desktop chrome-remote-desktop_bak
sudo wget -qO- "https://gist.githubusercontent.com/nightuser/2ec1b91a66ec33ef0a0a67b6c570eb40/raw/b09250dcc9a28f09de93192a948dffb4963c2aca/use_existing_session.patch" | tail -n +5 > ~/use_existing_session.patch
sudo patch -Np1 -i ~/use_existing_session.patch
rm ~/use_existing_session.patch
systemctl restart chrome-remote-desktop@$USER.service
systemctl enable chrome-remote-desktop@${USER}.service
systemctl status chrome-remote-desktop@$USER.service

Path file

References

  1. Use existing session chrome remote desktop patch (Note: the .patch file cannot applied directly to the origin "/opt/google/chrome-remote-desktop/chrome-remote-desktop" , manual applying the differences is necessary.)
  2. How to Install chrome-remote-desktop on Arch
  3. systemd: How to unmask a service whose unit file is empty
  4. Disable wayland support
  5. Sample configuration files

2022年3月23日 星期三

Enable remote control to work even before logging in Ubuntu

Problems

Login to remote PC is not working anymore after rebooting Ubuntu 20.04 remote machine


Solutions

1. SSH to the remote machine
2. Edit file "/etc/gdm3/custom.conf"
3. Add the line "WaylandEnable=false"
4. Restart the gdm with "sudo systemctl restart gdm3"
5. Re-login teamviewer

References

2021年11月8日 星期一

Cannot install npm modules "cross-env"

Problems

Installing npm module "cross-env" states the following error

npm error on every command: EEXIST: file already exists, mkdir 'c:\users\user\appdata\Roaming\npm'

Troubleshoot

  1. Try re-installing the module -> no luck
  2. Try installing with "npm install --force --save-dev cross-env" -> no luck
  3. Try removing npm cache -> no luck
Solutions
Turns out I have put the npm start scripts before actually install the module, which is the cause of the error, DO NOT update the script with the command "cross-env" before installing it.

References

2021年9月23日 星期四

Pipeline failed after changing the desktop machine and upgrading Ubuntu

Background

Recently I have changed my desktop to a mini PC and update the Ubuntu system from v18 to v20, which cause the gitlab runner failed to run.








The annoying part is that it only outputs "Job failed! exit status 1" which provides no clue for my debugging.


Troubleshooting and Solutions

Retrieve more debugging information using "journalctl -u gitlab-runner", which did provides some clues with the following





But it still is not enough for my debugging, I then find out with the help of the reference links, stated that the ".bash_logout" script of the user "gitlab-runner" is the cause of the issue. Every time when the runner use user gitlab-runner and exit (logout) the account, under the logout script, clear_console script 






is being called which gitlab-runner user does not have any privileges. Commenting the clear console script and re-run the runner solved the issue.


References

2021年9月12日 星期日

Printing image in non POSIX system

Background

In a project which needs to print receipt using heat sensitive printer, I successfully print out the receipt for each take away ordering, like below

Existing version of the receipt contains only text, using node module printer I was able to print the text properly, but recently a new request requires to print the qr code, which is in the form of an image, which this node module is not supported.








Somehow only CUPS printer support image printing which is not what Windows is supporting...


Solutions

So luckily I keep searching in the issue thread of the node printer plugin, and found this thread









So from the reply, I agree that there is no need for me to use time for finding node plugins, instead I follow the path to use a Windows application "printhtml" to first generate a HTML file and then print it.


Although it is quite a bit complicated, as I need to create a child process in my node application and execute the remote command, but it finally works.


Steps

  1. In loopback application, send socket message to the remote node daemon which that PC is connecting to the printer.

  2. The node daemon received the socket message and generate the HTML file (with the QR code image)

  3. Execute the child process and run the printhtml executable and print success.
References

2021年9月3日 星期五

Clone system disk from larger to smaller size HDD

Items

  1. Windows 10 USB (for fixing MBR)
  2. Gparted USB

Procedure

  1. Bootup the GParted USB
  2. Shrink the volume of the large HDD enough for the smaller HDD to save to
  3. Copy all the partitions of the source HDD to destination HDD
  4. Reboot the system
  5. Boot up the Windows 10 USB
  6. Repair Windows MBR partition
    1. Choose troubleshoot > command prompt
    2. Type Diskpart
    3. List disk > sel disk X, where X is the one of the new HDD
    4. List vol 
    5. Sel vol X, where X is the EFI partition (the one with ~500MB volume)
    6. assign letter=V:
    7. Type "exit"
    8. Type "V:"
    9. Type "bcdboot X:\windows /s V: /f UEFI"

References