Tuesday, March 29, 2022

HOWTO force monitor resolution on mxlinux

After recent upgrade, MX Linux could no longer detect my Viewsonic 22 inch monitor.

Due to unknown, the system therefore set the display to a very primitive resolution - VGA 1024x768 (4:3).

According to the monitor spec (from google), natively it should support 1680x1050 (16:10).



run command:

$ cvt 1680 1050

# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz

Modeline "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync



Add the native mode to display port 0, which is how I connect my monitor:

xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync

xrandr

xrandr --addmode DisplayPort-0 1680x1050_60.00



If want to config it every time log in, append the following to .profile


xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync

xrandr --addmode DisplayPort-0 1680x1050_60.00

#xrandr --output DisplayPort-0 --off --output DVI-0 --mode 2048x1536_60.00 --pos 0x0 --rotate normal --output HDMI-0 --off

xrandr --output DisplayPort-0 --mode 1680x1050_60.00 --pos 0x0 --rotate normal


Labels: , ,

Tuesday, March 22, 2022

How to ssh pipe copy files from remote to local compressed

ssh  john@192.168.1.49  "cd ~/Documents && tar -cf - assignments/ | gzip -9"  >  assignments.tar.gz


# syntax explanation

ssh    username@remoteIP     "command string"


Labels: , , ,

macOS howto format usb drive to dos compatible, max 4GB

 diskutil eraseDisk FAT32 MY_DISK1 /dev/disk2

Labels: , ,

Friday, March 11, 2022

sed command on OSX not supporting '+' or '?' by default

Regex pattern has 3 ways to indicate the occurrence of a character:

"c*"        matching letter 'c'    0 to N    times
"c+"       matching letter 'c'     1 to N    times
"c?"        matching letter 'c'    0 or 1     time

For example, if you want to replace "p...c" in input string,   INSTR="aaabbbcccpppccc"

On Linux, you do        echo $INSTR | sed 's/p\+c/_/'

The same thing on OSX not working, just failed silently.

$ echo $INSTR | sed 's/p\+c/_/'

aaabbbcccpppccc

$ echo $INSTR | sed 's/p+c/_/'

aaabbbcccpppccc


This is because, by default on OSX, sed interprets basic regex.  Instead, we specify using extended regex (-E)

$ echo $INSTR | sed -E 's/p+c/_/'

aaabbbccc_cc

We don't want '*' or the early ccc will be matched.

$ echo $INSTR | sed -E 's/p*c/_/'

aaabbb_ccpppccc

This in fact gives the same result as 's/z*c/_' because 'z' can be zero time

Now, similarly, to indicate 0 or 1 time, use -E as well

$ echo $INSTR | sed -E 's/p?c/_/'

aaabbb_ccpppccc

$ echo $INSTR | sed -E 's/b?c/_/'

aaabb_ccpppccc






Labels: , , ,