From 753824bc1593f45380ecf180c24229af4f78c4ce Mon Sep 17 00:00:00 2001 From: lhark Date: Thu, 8 Apr 2021 23:32:48 +0200 Subject: [PATCH 1/4] Regroup android tips, and add docs on runit logging --- how_to | 192 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 77 deletions(-) diff --git a/how_to b/how_to index 0fb2e94..b1ba7ac 100644 --- a/how_to +++ b/how_to @@ -703,9 +703,121 @@ Better Bibtex, Zotero: Bumblebee runit fix: sed -i 's/Driver=$/Driver=nvidia/' /etc/bumblebee/bumblebee.conf -Uncompress android .ab backup files: - # https://stackoverflow.com/questions/18533567/how-to-extract-or-unpack-an-ab-file-android-backup-file - ( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 backup.ab ) | tar xfvz - +Runit logging: + socklog + * syslogd replacement + * gets messages sent via syslog() (into /dev/log) + svlogd + * builtin log rotation + * needs to be setup for each service (/etc/runit/sv//log/run) + `exec chpst -u log svlogd -tt /var/log/` + $ sudo mkdir /var/log/ + $ sudo chown -R :log /var/log/ + $ sudo chmod g+w /var/log/ + runsvdir + * sends its stdout to /dev/console + * sends its stderr to its own command line (ps aux | grep runsvdir) + runsv + * if /log exists, redirects service's stdout to logger's stdin + * by default, runsv's stderr, stdout (and stdin?) are redirected to /dev/console +Android: + Uncompress android .ab backup files: + # https://stackoverflow.com/questions/18533567/how-to-extract-or-unpack-an-ab-file-android-backup-file + ( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 backup.ab ) | tar xfvz - + + Setup udev for android device with adb: + # Solves "adb: error: failed to get feature set: insufficient permissions for device" + # https://wiki.archlinux.org/index.php/Android_Debug_Bridge#Adding_udev_Rules + Get Vendor and and product IDs with + $ lsusb + Bus 001 Device 007: ID 0fce:8161 Sony Ericsson Mobile Communications AB ST18i + ^ ^ + / \ + Vendor ID Product ID + Create adbusers group and yourself to it + $ sudo groupadd adbusers + $ sudo usermod -aG adbusers + /etc/udev/rules.d/51-android.rules: + SUBSYSTEM=="usb",ATTR{idVendor}=="", MODE="0660", GROUP="adbusers" # Or sdkusers + SUBSYSTEM=="usb",ATTR{idVendor}=="",ATTR{idProduct}=="",SYMLINK+="android_adb" + SUBSYSTEM=="usb",ATTR{idVendor}=="",ATTR{idProduct}=="",SYMLINK+="android_fastboot" + $ sudo udevadm control --reload-rules + + Setup android emulator: + trizen -S android-emulator \ + android-google-apis-x86-system-image-23 \ + android-sdk-cmdline-tools-latest # Some tools are borked in the original package + source /etc/profile # Update PATH + # avdmanager will complain about permissions at first start but will + # happily put AVDs in /root/.android/avd if you let it have it for too long + /opt/android-sdk/cmdline-tools/latest/bin/avdmanager create avd \ + --force \ + --name \ + --package 'system-images;android-23;google_apis;x86' # Match path in /opt/android-sdk/system-images/ + # AVD is stored in ~/.android/avd/ + # Enable using the hardware keyboard, and switch layout to azerty + sed -i -e 's/\(hw.keyboard=\).*/\1yes/' \ + -e 's/\(hw.keyboard.charmap=\).*/\1azerty/' \ + ~/.android/avd/.avd/config.ini + # If you have issues running image from different arch, try checking the PATH or + # https://www.bram.us/2017/05/12/launching-the-android-emulator-from-the-command-line/ + emulator -avd + + Android diagnostic debug phone codes: + # https://www.itworld.com/article/2708985/debug-your-phone-with-these-hidden-android-secret-codes.html + # https://www.redmondpie.com/hidden-android-secret-codes-for-samsung-htc-motorola-sony-lg-and-other-devices/ + *#06# – IMEI number + *#0*# – Enter the service menu on newer phones like Galaxy S III + *#*#4636#*#* – Phone information, usage statistics and battery + *#*#34971539#*#* – Detailed camera information + *#*#273282*255*663282*#*#* – Immediate backup of all media files + *#*#197328640#*#* – Enable test mode for service + *#*#232339#*#* – Wireless LAN tests + *#*#0842#*#* – Backlight/vibration test + *#*#2664#*#* – Test the touchscreen + *#*#1111#*#* – FTA software version (1234 in the same code will give PDA and firmware version) + *#12580*369# – Software and hardware info + *#9090# – Diagnostic configuration + *#872564# – USB logging control + *#9900# – System dump mode + *#301279# – HSDPA/HSUPA Control Menu + *#7465625# – View phone lock status + *#*#7780#*#* – Reset the /data partition to factory state + *2767*3855# – Format device to factory state (will delete everything on phone) + ##7764726 – Hidden service menu for Motorola Droid + *#*#7594#*#* – Enable direct powering down of device once this code is entered + *#*#273283*255*663282*#*#* – Make a quick backup of all the media files on your Android device + *#*#232338#*#* – Shows Wi-Fi MAC address + *#*#1472365#*#* – Perform a quick GPS test + *#*#1575#*#* – For a more advanced GPS test + *#*#0283#*#* – Perform a packet loopback test + *#*#0*#*#* – Run an LCD display test + *#*#0289#*#* – Run Audio test + *#*#2663#*#* – Show device’s touch-screen version + *#*#0588#*#* – Perform a proximity sensor test + *#*#3264#*#* – Show RAM version + *#*#232331#*#* – Run Bluetooth test + *#*#232337#*# – Show device’s Bluetooth address + *#*#7262626#*#* – Perform a field test + *#*#8255#*#* – Monitor Google Talk service + *#*#4986*2650468#*#* – Show Phone, Hardware, PDA, RF Call Date firmware info + *#*#1234#*#* – Show PDA and Phone firmware info + *#*#2222#*#* – Show FTA Hardware version + *#*#44336#*#* – Show Build time and change list number + *#*#8351#*#* – Enable voice dialing log mode, dial *#*#8350#*#* to disable it + ##778 (+call) – Show EPST menu + These codes are specific to HTC devices only: + *#*#3424#*#* – Run HTC function test program + *#*#4636#*#* – Show HTC info menu + ##8626337# – Run VOCODER + ##33284# – Perform field test + *#*#8255#*#* – Launch Google Talk service monitor + ##3424# – Run diagnostic mode + ##3282# – Show EPST menu + ##786# – Reverse Logistics Support + + Android wpa_supplicant conf file path: + /data/misc/wifi/wpa_supplicant.conf Fix: Failed to activate service 'org.freedesktop.login1': timed out: If dbus has been restarted, don't forget to restart elogind/systemd-logind @@ -780,24 +892,6 @@ Image/photo sorting with feh: feh --action1 'mv -v %F "/path/to/target/"%N' \ --action[2-9] [...] /dir/to/sort -Setup udev for android device with adb: - # Solves "adb: error: failed to get feature set: insufficient permissions for device" - # https://wiki.archlinux.org/index.php/Android_Debug_Bridge#Adding_udev_Rules - Get Vendor and and product IDs with - $ lsusb - Bus 001 Device 007: ID 0fce:8161 Sony Ericsson Mobile Communications AB ST18i - ^ ^ - / \ - Vendor ID Product ID - Create adbusers group and yourself to it - $ sudo groupadd adbusers - $ sudo usermod -aG adbusers - /etc/udev/rules.d/51-android.rules: - SUBSYSTEM=="usb",ATTR{idVendor}=="", MODE="0660", GROUP="adbusers" # Or sdkusers - SUBSYSTEM=="usb",ATTR{idVendor}=="",ATTR{idProduct}=="",SYMLINK+="android_adb" - SUBSYSTEM=="usb",ATTR{idVendor}=="",ATTR{idProduct}=="",SYMLINK+="android_fastboot" - $ sudo udevadm control --reload-rules - Get original windows key from linux: # From: https://twitter.com/BrandonPrry/status/1038269038881898498 # Not guaranted to work @@ -819,62 +913,6 @@ MSI ge62 webcam not found: Air Canada PNR access: https://services.aircanada.com/ServicingPNR/Ancillary/ACO/ -Android diagnostic debug phone codes: - # https://www.itworld.com/article/2708985/debug-your-phone-with-these-hidden-android-secret-codes.html - # https://www.redmondpie.com/hidden-android-secret-codes-for-samsung-htc-motorola-sony-lg-and-other-devices/ - *#06# – IMEI number - *#0*# – Enter the service menu on newer phones like Galaxy S III - *#*#4636#*#* – Phone information, usage statistics and battery - *#*#34971539#*#* – Detailed camera information - *#*#273282*255*663282*#*#* – Immediate backup of all media files - *#*#197328640#*#* – Enable test mode for service - *#*#232339#*#* – Wireless LAN tests - *#*#0842#*#* – Backlight/vibration test - *#*#2664#*#* – Test the touchscreen - *#*#1111#*#* – FTA software version (1234 in the same code will give PDA and firmware version) - *#12580*369# – Software and hardware info - *#9090# – Diagnostic configuration - *#872564# – USB logging control - *#9900# – System dump mode - *#301279# – HSDPA/HSUPA Control Menu - *#7465625# – View phone lock status - *#*#7780#*#* – Reset the /data partition to factory state - *2767*3855# – Format device to factory state (will delete everything on phone) - ##7764726 – Hidden service menu for Motorola Droid - *#*#7594#*#* – Enable direct powering down of device once this code is entered - *#*#273283*255*663282*#*#* – Make a quick backup of all the media files on your Android device - *#*#232338#*#* – Shows Wi-Fi MAC address - *#*#1472365#*#* – Perform a quick GPS test - *#*#1575#*#* – For a more advanced GPS test - *#*#0283#*#* – Perform a packet loopback test - *#*#0*#*#* – Run an LCD display test - *#*#0289#*#* – Run Audio test - *#*#2663#*#* – Show device’s touch-screen version - *#*#0588#*#* – Perform a proximity sensor test - *#*#3264#*#* – Show RAM version - *#*#232331#*#* – Run Bluetooth test - *#*#232337#*# – Show device’s Bluetooth address - *#*#7262626#*#* – Perform a field test - *#*#8255#*#* – Monitor Google Talk service - *#*#4986*2650468#*#* – Show Phone, Hardware, PDA, RF Call Date firmware info - *#*#1234#*#* – Show PDA and Phone firmware info - *#*#2222#*#* – Show FTA Hardware version - *#*#44336#*#* – Show Build time and change list number - *#*#8351#*#* – Enable voice dialing log mode, dial *#*#8350#*#* to disable it - ##778 (+call) – Show EPST menu - These codes are specific to HTC devices only: - *#*#3424#*#* – Run HTC function test program - *#*#4636#*#* – Show HTC info menu - ##8626337# – Run VOCODER - ##33284# – Perform field test - *#*#8255#*#* – Launch Google Talk service monitor - ##3424# – Run diagnostic mode - ##3282# – Show EPST menu - ##786# – Reverse Logistics Support - -Android wpa_supplicant conf file path: - /data/misc/wifi/wpa_supplicant.conf - Grub2 theme customization: theme.txt reference: http://wiki.rosalab.ru/en/index.php/Grub2_theme_/_reference#Main_file_syntax From 56735cbacc3056204960288ffd0db9444bfcd5f6 Mon Sep 17 00:00:00 2001 From: lhark Date: Thu, 8 Apr 2021 23:41:14 +0200 Subject: [PATCH 2/4] Some tips on doing secure backups via ssh --- how_to | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/how_to b/how_to index b1ba7ac..89ad433 100644 --- a/how_to +++ b/how_to @@ -856,6 +856,18 @@ ssh: ssh-keygen -t ed25519 -a 100 Good ol' RSA, with 4096 bits for good measure ssh-keygen -t rsa -b 4096 -o -a 100 + Restricted access for backups: + Create system user with no password, give it a HOME and a group (or use a backup group) + Prepend key in .ssh/authorized_keys with + command="scp -f /path/to/",no-agent-forwarding,no-port-forwarding,no-pty,no-X11-forwarding ssh-rsa AAAAB[...] + Setup rssh + pacman -S rssh + # Access bits order: rsync, rdist, cvs, sftp, scp, svnserve + echo "user=::000010:" >> /etc/rssh.conf + sudo chsh -s /usr/bin/rssh + Fix key auth: + chmod 700 ~/.ssh/ + chmod 600 ~/.ssh/authorized_keys Run MSVC on linux with Wine: As seen on the internet, not tested: From 4564239dc395011bd272f8af88adaf02cbb27c9d Mon Sep 17 00:00:00 2001 From: lhark Date: Thu, 8 Apr 2021 23:43:10 +0200 Subject: [PATCH 3/4] Misc tips (sway keyboard, old bluetooth tools, deb packages) --- how_to | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/how_to b/how_to index 89ad433..956a4b6 100644 --- a/how_to +++ b/how_to @@ -31,6 +31,8 @@ Usefull packages : lnav Backlight management: light # http://haikarainen.github.io/light/ + IRC: + catgirl # https://git.causal.agency/catgirl System setup: display/drivers: @@ -459,6 +461,8 @@ Borg backup: Serial terminal st -l /dev/ttyUSB0 + # Or + minicom -D /dev/ttyUSB0 -b Wifi AP: https://wiki.archlinux.org/index.php/Software_access_point @@ -627,7 +631,8 @@ Install 64 bits kernel on 32 bits system (and 64 bits hardware) (bad idea) Compile C for ATmega328p/Arduino: sudo xbps-install -S avr-gcc avr-libc avrdude - sudo usermod -aG dialout # Or /dev/ttyACM0 group + sudo pacman -S avr-libc avrdude + sudo usermod -aG dialout # Or /dev/ttyACM0 group (might be uucp) avr-gcc -g -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o .o .c avr-gcc -mmcu=atmega328p .o -o @@ -1108,3 +1113,17 @@ GPG: > expire ... > save + +sway / wayland: + Get current active (first) keyboard layout name: + # https://queer.hacktivis.me/objects/73823f56-1954-44fe-b046-39e726cca67b + swaymsg -t get_inputs | jq 'map(select(.type == "keyboard"))[0].xkb_active_layout_name' + +Bluetooth: + Get access to deprecated gatttool and hcitool: + trizen -S bluez-utils-compat + Add `--disable-systemd` to ./configure command on Artix + +Extract debian .deb package: + ar x .deb + tar xf data.tar.xz From ff55ddce61627564f9e00e94991e9a07649297a8 Mon Sep 17 00:00:00 2001 From: lhark Date: Fri, 9 Apr 2021 12:04:33 +0200 Subject: [PATCH 4/4] Add docx to text methods --- how_to | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/how_to b/how_to index 956a4b6..2536e19 100644 --- a/how_to +++ b/how_to @@ -1127,3 +1127,9 @@ Bluetooth: Extract debian .deb package: ar x .deb tar xf data.tar.xz + +Convert docx to text format in CLI: + # Better fidelity wrt. the document layout + docx2txt .docx + # Can output markdown + pandoc .docx -o .md