/yoga-c630-linux-kernel

Linux kernel with yoga c630 specific patches...and maybe a little more

OtherNOASSERTION

OKAY So havent updated much since 5.12 cuz of various graphic driver issues. The only remaining one is "dpu encoder timeout" If not running compiz it will just slow you down and spam your log files to rediculous sizes. Unfortunatly compiz freezes so anything your working on is lost wo extreme measures. The dpu encoder seems to have become slightly less often with newer kernels. Whats in here well the cpu turbo freq is now considered a reg freq cuz so many patches over so many kernel versions couldnt get it to work, like it simply wouldnt go into that freq ever. Now all is good. Using slightly older sound stack cuz of breaks in recent versions. FTDI mpsse drivers for i2c and spi look into the tools/16ton folder for support. Also an actual schematic for this laptop! Is in tools/16ton as well. As per usual the various wifi restrictions for ath10k have been removed no more no-ir/radar/tx-power limits from crda or from AP, all of 2.4ghz is open etc. I hardbake the regulatory.db file directly into the kernel but the crda/wireless-reg files I used are in tools/16ton. Some other various drivers for usb-to-i2c etc have been added and usb devices etc. Various little c630 fixes. I will mention altho it recovers from them fine the wifi driver has picked up some rather very common and intrusive issues as of late. Its unrelated to my wifi patches I always test seperatly. But dont be surprised if logs fill up with ATH errors. Oh and sound too no matter which sound stack they all have a ton of errors reported to logs. I was going thru and limiting the various log spammers, but I eventually got tired of keeping up with it. The information below is mostly legacy stuff tho sum may still apply. The supported hardware is old. Altho I havent personally tested the cellular modem has drivers and everything it needs, and I do believe the Displayport over usb-c has most, if not everything it needs. The DPort may need a out of tree patch or two I havent looked into it.

kernel version 5.12.x apparently needs newer a630_sqe.fw I deleted my windows install so not sure
if it came downin updates but i grabbed from here;
https://anduin.linuxfromscratch.org/sources/linux-firmware/qcom/
seems to work fine for me so far

This is for the qualcomm aarch64 laptop YOGA C630, with this kernel and these directions expect the following
    WORKS;
        accelerated graphics
            panel
        audio speakers/headphones (no internal mic)
        wifi
        bluetooth
        usb
        touchpad/keyboard/touchscreen
        camera
        battery meter (UPDATE much better reporting now thanks to a patch found at steevs kernel)
	    Venus video encoder/decoder
	    CPU turbo/boost frequencies

    UNTESTED BUT POSSIBLE
        LTE cell modem (My understanding is it needs an active sim and connection to tower with active data connection to present,
	    i have no sim)
        DisplayPort over usb-c (I don't have a cable, and we dont have a working usb type-c driver)

    DOESN'T'T WORK
        LTE cell modem (My understanding is it needs more work, like context channels, possible changes to sum protocols and ip tools)
        Internal mic (which i believe is some sorta mic array with its own firmware "qcwdsp850.mbn"?)
        Sensor Low Power Island  (im not sure if this includes the accelerometer or just temp etc firmware files qcslpi850.mbn
	qcslpi850_cls.mbn ive found no patches/dev?)

    UPDATE: Big shout out to Steev , his kernel has become the defacto kernel for linaro, He keeps bringing in awesome
    UPDATE: patches, he introduced me to pwcli where i found the ath10k patches for not waiting on dead device (gamechanger)
    UPDATE: And on top of all that despite the extreme gap between our intelligence and skill he still gives me a hand.
    UPDATE: Thank you Steev!! https://steev.net/tags/c630/   https://github.com/steev/
    ALL CREDIT GOES TO THE GODS AT LINARO, id list names but i dont know who everyone is and what they do. i was adding patches
    from at least a half dozen places before finding Anderssons github page. That guy must be like the Gandolph of awesome
    programmers, so so many patches have come from him. i digress anyway;
    This assumes you have already followed the directions from
    https://github.com/aarch64-laptops/build
    and you have the four services installed (NEWEST POSSIBLE SOURCE REQUIRED) and you followed wifi link at
    https://github.com/aarch64-laptops/build/blob/master/misc/lenovo-yoga-c630/wifi/README.md
    and the gpu link
    https://github.com/aarch64-laptops/build/blob/master/misc/lenovo-yoga-c630/gpu/README.md
    and then HOPEFULLY followed the ubuntu system upgrade instructions at the bottom of the README to ubuntu 20.04
    newer versions of alsa and pulseaudio are required for ucm2 tho ucm did work and i believe didnt have the sync
    issues if using =>5.7kernels

Booting the remote procs
    get the firmware from windows partition
    UPDATE: the c630/yoga_fw_extract.sh fil in kernel source has my hacked up celliwig yoga_fw_extract.sh for all this stuff and more.
        wget https://raw.githubusercontent.com/Celliwig/Lenovo-Yoga-c630/master/yoga_fw_extract/yoga_fw_extract.sh
        chmod +x yoga_fw_extract.sh
        ./yoga_fw_extract.sh
    kernel 5.5 and newer need a diff firmware directory
        sudo mkdir -p /lib/firmware/qcom/LENOVO/81JL
        sudo cp  /lib/firmware/qcom/c630/* /lib/firmware/qcom/LENOVO/81JL/
        we also need qcdxkmsuc850.mbn ipa_fws.elf qcvss850.mbn
    EXAMPLE; use same method to find
        sudo find /mnt -name qcdxkmsuc850.mbn  (it may find multiple ls -la them and use the newest)
    INSTALL FIRMWARE;
        cp qcdxkmsuc850.mbn /lib/firmware/qcom/LENOVO/81JL
    ipa_fws.elf; use pil-splitter.py found in this kernels C630 folder or
    https://github.com/remittor/qcom-mbn-tools/blob/master/pil-splitter.py
        python2 pil-splitter.py ipa_fws.elf ipa_fws    then copy the resulting files to /lib/firmware
    qcvss850.mbn is the firmware for venus enc/dec which currently doesnt work on c630.(UPDATE: VENUS WORKS NOW!) the venus mods link to mdt_loader which
    means it should be able to load the "full" .mdt file. ive tried both split and full it loads without the metadata error
    but doesnt reset. eitherway;
    SINGLE FILE METHOD;
        mkdir /lib/firmware/qcom/venus-5.2
        cp qcvss850.mbn /lib/firmware/qcom/venus-5.2/venus.mdt
    SPLIT FILE METHOD;
        mkdir /lib/firmware/qcom/venus-5.2
        python2 pil-splitter.py qcvss850.mbn venus
        cp venus* /lib/firmware/qcom/venus-5.2/

    Now their are sum .jsn files that i dont know what are used for but well grabem in case
        git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
        sudo cp linux-firmware/qcom/sdm845/*.jsn /lib/firmware/qcom/LENOVO/81JL/
    BLUETOOTH firmwares are in linux-firmware/qca/*
    Now we want to add the required firmware files to the initrd but celliwig saved the day with initramfs-tools hook that does this for us
        wget https://github.com/Celliwig/Lenovo-Yoga-c630-packages/raw/master/initramfs-tools-firmware/initramfs-tools-firmware_0.1_all.deb
        sudo dpkg -i initramfs-tools-firmware_0.1_all.deb
        sudo update-initramfs -k $(uname -r) -c
    If installed on older kernel update /etc/initramfs-tools/firmware to look like this;
qcom/LENOVO/81JL/qcdsp1v2850.mbn
qcom/LENOVO/81JL/qcdsp2850.mbn
qcom/LENOVO/81JL/qccdsp850.mbn
qcom/LENOVO/81JL/qcadsp850.mbn

GRUB;
	Grub needs a few boot options added. edit /etc/default/grub find the line;
		GRUB_CMDLINE_LINUX_DEFAULT="efi=novamap"
	and replace with
		GRUB_CMDLINE_LINUX_DEFAULT="efi=novamap pd_ignore_unused clk_ignore_unused"
	sudo update-grub  (will update the new settings)

INSTALLING KERNEL!!!!
	I have my own defconfig called 16ton_defconfig, just make 16ton_defconfig  to use my config (constantly changing and
	possibly experimental) The default hooks that deal with the .dts files are wrong. We have two options 1 patch the script for the
	c630 or manually make a directory and copying/renaming the dtb before every kernel install.
    OUTDATED OPTION 1 PATCH;  # everything works automagically, the patch is in this kernels C630 folder its called functions.patch
    OUTDATED     cd /usr/share/flash-kernel
    OUTDATED     sudo patch -p1 < /path-to-patch/functions.patch
    OUTDATED OPTION 2 MANUAL; in this example we are installing linux-image-5.7.0-rc1_5.7.0-rc1-1_arm64.deb and
    OUTDATED we have sdm850-lenovo-yoga-c630.dtb
    OUTDATED 	sudo mkdir /usr/lib/linux-image-5.7.0-rc1
    OUTDATED 	sudo cp sdm850-lenovo-yoga-c630.dtb /usr/lib/linux-image-5.7.0-rc1/laptop-lenovo-yoga-c630.dtb
    OUTDATED 	sudo dpkg -i linux-image-5.7.0-rc1_5.7.0-rc1-1_arm64.deb
    UPDATE      Just install aarch64-laptops-support-ubuntu20.04.1_all.deb from the C630 folder
                sudo dpkg -i aarch64-laptops-support-ubuntu20.04.1_all.deb
                      If you used my patch before, restore the functions file by reinstalling flash-kernel
                sudo apt-get reinstall flash-kernel
                If flash-kernel fails to install/configure simply edit
                /var/lib/dpkg/info/flash-kernel.postinst
                change the end

                else
	                flash-kernel

                fi

                to;

                else
	                flash-kernel
                #    ls > /dev/null
                fi

                then run sudo apt-get -f install now u can install aarch64-support
                I changed the file back after flash-kernel installed but doubt need to





GRUB the bootloader requires a couple of options pd_ignore_unused clk_ignore_unused efi=novamap
        sudo pluma /etc/default/grub
    change line starting with GRUB_CMDLINE_LINUX_DEFAULT=  to
    GRUB_CMDLINE_LINUX_DEFAULT="efi=novamap pd_ignore_unused clk_ignore_unused"
        sudo update-grub

Audio;
    get the ucm2 files from;
    UPDATE: this could be newer https://github.com/Srinivas-Kandagatla/alsa-ucm-conf/tree/C630
        https://git.linaro.org/people/srinivas.kandagatla/alsa-ucm-conf.git
        or this kernels C630 folder
    copy ucm2 files
        sudo cp alsa-ucm-conf/ucm2/codecs/w* /usr/share/alsa/ucm2/codecs/
        sudo cp -R alsa-ucm-conf/ucm2/Lenovo-YOGA-C630-13Q50 /usr/share/alsa/ucm2/
    diff models require diff folder names
        sudo cp -R /usr/share/alsa/ucm2/Lenovo-YOGA-C630-13Q50 /usr/share/alsa/ucm2/Lenovo-YOGA-C63
        sudo cp /usr/share/alsa/ucm2/Lenovo-YOGA-C630-13Q50/Lenovo-YOGA-C630-13Q50.conf /usr/share/alsa/ucm2/Lenovo-YOGA-C63/Lenovo-YOGA-C63.conf
    POSSIBLE ISSUES; My machine lists the sound card as disabled with dummy output on cold boot, every time i shutdown it panics
    	reboots *FIXED, on reboot sound card comes up and can be used after switching to headphones out then move volume bar then
	select speakers. To have sound on cold boot, first get sound working (if you cant get sound working u can try the
	asound.state.head in C630/var/lib/alsa/
	just cp it to /var/lib/alsa/alsa.state and skip the alsactl store step) then switch output to headphones.
        	sudo alsactl store
        	sudo chattr +i /var/lib/alsa/alsa.state
    	Now cold boot should present enabled soundcard just switch to headphones change volume and switch back to speakers
    OLDER UCM INSTALLS; use the old ucm files from here; #or this kernels C630 folder
        git clone https://github.com/andersson/alsa-lib.git
        sudo cp -R alsa-lib/src/conf/ucm/LENOVO-81JL-LenovoYOGAC630_13Q50-LNVNB161216 /usr/share/alsa/ucm/
        sudo cp -R /usr/share/alsa/ucm/LENOVO-81JL-LenovoYOGAC630_13Q50-LNVNB161216 /usr/share/alsa/ucm2/Lenovo-YOGA-C63
        sudo cp /usr/share/alsa/ucm2/Lenovo-YOGA-C63/LENOVO-81JL-LenovoYOGAC630_13Q50-LNVNB161216.conf /usr/share/alsa/ucm2/Lenovo-YOGA-C63/Lenovo-YOGA-C63.conf
        sudo cp -R /usr/share/alsa/ucm/LENOVO-81JL-LenovoYOGAC630_13Q50-LNVNB161216 /usr/share/alsa/ucm2/Lenovo-YOGA-C630-13Q50
        sudo cp /usr/share/alsa/ucm2/Lenovo-YOGA-C63/LENOVO-81JL-LenovoYOGAC630_13Q50-LNVNB161216.conf /usr/share/alsa/ucm2/Lenovo-YOGA-C630-13Q50/Lenovo-YOGA-C630-13Q50.conf
    FIXES;
    linux 5.5.0 with ucm (not ucm2) files the audio was messed up for first 30 seconds of play and pops could be heard after, non of these issues on newer alsa ucm2 and
    kernel 5.7.0 PULSEAUDIO its possible on older ucm install the issues could have been helped with the tsched option for pulseaudio
        sed -i "s|^load-module module-udev-detect|load-module module-udev-detect tsched=0|" ${D}${sysconfdir}/pulse/default.pa
    automate the switching of speakers/headphons volume fix/hack, scripts found in C630/usr/local/bin/sound-fix.sh
        sudo cp C630/usr/local/bin/sound-fix.sh /usr/local/bin/sound-fix.sh
        sudo chmod +x /usr/local/bin/sound-fix.sh
    then add to your window manager autostart. if issues i suggest playing with the sleep variables placement/timing
    or removing them entirely and have /etc/xdg/autostart/pulseaudio.desktop run the script.
    I also included my alsa.state files for both headphones (required) and speakers in C630 folder

Wifi;
    the wlanmdsp.mbn from newer linux-firmware package is better more stable then one on windows partition
    ISSUE     chan info event message "received chan info event without a scan request, ignoring"
    ISSUE     the firmware file from linux-firmware doesnt have single-chan-info-per-channel set
    ISSUE     This will have to be done after every single linux-firmware package update/upgrade
    UPDATE     the ath10k-fwencoder in C630/wifi-extra/ath10k-scripts/ath10k-fwencoder is pre-edited or
    UPDATE     git clone https://github.com/qca/qca-swiss-army-knife.git
    UPDATE     This version currently has a typo edit ath10k-fwencoder and change
    UPDATE     'mgmt-tx-by-ref': ATH10K_FW_FEATURE_MGMT_TX_BY_REF,
    UPDATE              to;
    UPDATE     'mgmt-tx-by-reference': ATH10K_FW_FEATURE_MGMT_TX_BY_REF,
    UPDATE              then;
    UPDATE     cd qca-swiss-army-knife/tools/scripts/ath10k/
    UPDATE     cp /lib/firmware/ath10k/WCN3990/hw1.0/firmware-5.bin ./
    UPDATE     ./ath10k-fwencoder --modify --features=wowlan,mgmt-tx-by-reference,non-bmi,single-chan-info-per-channel  firmware-5.bin
    UPDATE     cp firmware-5.bin /lib/firmware/ath10k/WCN3990/hw1.0/firmware-5.bin

    SAME OPTIONS THE FIRMWARE ALREADY HAS ENABLED
    POSSIBLE ISSUES; If your upgrading to kernel >=5.6 qrtr-ns service has been moved to the kernel but the lib from the service is still needed. The current version of qrt-ns looks at kernel version
    disables itself if >=5.6, so if upgrading , upgrade qrtr-ns from https://github.com/andersson/qrtr
    ISSUE SCAN errors sum usrs have issues with network-monitors scanning, causing kernel errors and wifi crash. I cant reproduce but i have patched the official ubuntu source with the no-scan patch;
    https://github.com/bm16ton/yoga-c630-network-manager     it has a working debian folder so simply
        git clone https://github.com/bm16ton/yoga-c630-network-manager
        cd yoga-c630-network-manager
        sudo apt-get build-dep network-manager
        sudo dpkg-buildpackage -b -j$(nproc)
    Going into/out of monitor mode can cause kernel errors like "[  160.592818] WARNING: CPU: 1 PID: 2868 at net/mac80211/iface.c:417 ieee80211_add_virtual_monitor+0x250/0x278 [mac80211]"
    which will kill sudo/su etc. Ive found bringing the interface down first helps IE
        sudo ifconfig wlan0 down
        sudo systemctl stop network-manager
        sudo airmon-ng check kill
        sudo airmon-ng start wlan0
        iwconfig
        sudo aireplay-ng --test wlan0mon
        sudo airmon-ng stop wlan0mon
        iwconfig
        sudo ifconfig wlan0 up
        sudo systemctl start network-manager

        IF YOU WANNA TRY MY WIFI PATCHES WITHOUT CHANGING YOUR INSTALLED CRDA BUILD MY KERNEL WITH CRDA BUILT IN
        EXAMPLE ON C630
        make 16ton-crda_defconfig
        make -j8
              THIS WILL ALLOW YOUR CARDS TXPOWER TO SKYROCKET TO 33DB FOR 2.4GHZ AND 30DB FOR 5GHZ i HIGHLY RECOMMEND SETTING IT TO SOMETHING SANE ON CONNECT
              CREATE FILE /etc/network/if-up.d/wifi-txpower AND ADD OUR SCRIPT
              sudo nano /etc/network/if-up.d/wifi-txpower
                    ADD CONTENTS

                #!/bin/bash

                if [ "$IFACE" = wlan0 ]; then
                iw wlan0 set txpower fixed 2200
                #    iwconfig wlan0 power off
                fi

              UNCOMMENT "iwconfig wlan0 power off" TO DISABLE POWERSAVING ON CARD CONNECT/UP
              THEN MAKE IT EXECUTABLE
        sudo chmod +x /etc/network/if-up.d/wifi-txpower
              REBOOT

CPU boost/turbo
    enabled in kernel by default in my kernel, make sure u use 16ton_defconfig or pick the correct thermal/cpufreq stuff,
    enable in userland with a root "echo 1 > /sys/devices/system/cpu/cpufreq/boost" disable with "echo 0 > /sys/devices/system/cpu/cpufreq/boost"
    id just add it to /etc/rc.local

GPU
    Needs shaders which the celliwig app doesnt get.
   OLD     wget http://releases.linaro.org/96boards/dragonboard845c/qualcomm/firmware/RB3_firmware_20190529180356-v4.zip
   OLD     unp RB3_firmware_20190529180356-v4.zip
   OLD     sudo cp $(find ./RB3_firmware_20190529180356-v4 -name a630_sqe.fw) /lib/firmware/qcom/
   OLD     sudo cp $(find ./RB3_firmware_20190529180356-v4 -name a630_gmu.fw) /lib/firmware/qcom/
   NEW     wget -O a630_gmu.bin https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/qcom/a630_gmu.bin
   NEW     wget -O a630_sqe.fw https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/qcom/a630_sqe.fw
   NEW     sudo cp a630_gmu.bin a630_sqe.fw /lib/firmware/qcom/
        sudo mount /dev/sda4 /mnt
        sudo find /mnt -name qcdxkmsuc850.mbn  (it may find multiple ls -la them and use the newest)
        sudo cp {path to qcdxkmsuc850.mbn} /lib/firmware/qcom/
    POSSIBLE ISSUES; the mesa packages had a bug where screens wouldnt redraw correctly especially text IE terminal-emulator, issue
    is fixed in master/20.1 but if using older mesa's then apply these patches depending on version
    19.3 https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5192
    20.0 https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5190
    20.1 https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5190
UPGRADING MESA;
    linaro keeps semi regular updated source packages with debian package support
        git clone https://git.linaro.org/landing-teams/working/qualcomm/pkg/mesa.git
        cd mesa
        sudo apt-get build-dep mesa
        sudo dpkg-buildpackage -b
NOTES;
     With kernel 5.7 and the recently released mesa 20.1.1, things like mupen64 and dolphin now work! mupen64 at full
     frame rate once audio/video sync is disabled and dolphin is slow in certain areas probly just needs correct settings.


VENUS DECODERS/ENCODERS
UPDATE: Stanimir Varbanov emailed me patches that get venus working!! This guy is awesome! thanks Stan!
UPDATE2: Requires the firmware from windows partition the linux-firware files wont work, so after every linux-firmware upgrade/update
UPDATE2: recopy the venus files.find qcvss850.mbn on windows partition use pil_splitter.py directions above or use script
UPDATE2: C630/venus-firmware-reinstall "sudo ./venus-firmware-reinstall" This script is just a dirty hackdown job of yoga_fw_extract.sh but works!
EXAMPLES;
	ffplay -sync video -autoexit -vcodec h264_v4l2m2m -i simpsons.mp4
	gst-launch-1.0 filesrc location=simpsons.mp4 ! qtdemux name=m m.video_0 ! h264parse ! v4l2h264dec capture-io-mode=dmabuf ! glimagesink


GPS
    the gps in on remoteproc so we need the pds protocol luckily linaro added this to gpsd
        git clone https://git.linaro.org/landing-teams/working/qualcomm/pkg/gpsd.git
        sudo apt-get build-dep gpsd
        sudo dpkg-buildpackage -b
    then install the libgps and gpsd debs then well disable the service and do things manually
        sudo systemctl disable gpsd.service
            open terminal
        sudo gpsd -N -D9 -F /var/run/gpsd.sock
            open another terminal
        sudo gpsdctl add pds://any
        sudo xgps
    POSSIBLE ISSUES, may hafta repeat the process of starting/configuring gpsd a couple of times especially if in area with
    low gps signal.

TOUCHPAD
    After hundreds of hours of use my touchpad is wearing down. It now constantly does "Tap and Drag" and is always copying files and text
    accidently. The last ditch option is to turn this off. The official answer with dconf editor did not work for me but synclient did
         synclient TapAndDragGesture=0
    UPDATE: I wrote an extremely simple gui for synclient found here https://github.com/bm16ton/syn-gui

MODEM
    edit dts file (already in this kernel) and add the firmware
    find/download ipa_fws.elf from windows partition. use pil_splitter.py to split into files with prefix ipa_fws copy to
    firmware directory.it now shows in dmesg that the modem is booted. I cannot test further because i believe if i had an
    active sim once the modem connected to a tower and had data i would get a rmnet device that i could use ip to setup.
    something similiar to;
        ip link add link wwp0s20u5i2 name rmnet0 type rmnet mux_id 1
    and use something like qmicli or modemmanager to get it going?
	UPDATE; Needs more things mainlined, will try and keep an eye on this

USB PERIPHERAL
	unfortunatly the usb type-c stuff isnt working but we can boot with a port in peripheral (just cant switch to host without reboot)
	edit arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts and change;

&usb_1_dwc3 {
	dr_mode = "host";
};

to;

&usb_1_dwc3 {
	dr_mode = "peripheral";
};

	you can just compile the dtb with make dtbs, now boot with the new dtb file and install umtp from;
	https://github.com/viveris/uMTP-Responder
	start with umtprd-ffs.sh
	it requires the functionfs libcomposite kernel modules which i will add to the 16ton_defconfig

FIXES;
    SHUTDOWN;
        the system will crash on shutdown if connected to wireless AP.
	FIX; add this script/service which disconnects wifi at start of shutdown, in C630 directory
	    sudo cp C630/usr/local/bin/disconnect-wifi.sh /usr/local/bin/disconnect-wifi.sh
	    sudo chmod +x /usr/local/bin/disconnect-wifi.sh
            sudo cp C630/etc/systemd/system/iw-disconnect.service /etc/systemd/system/iw-disconnect.service
            sudo systemctl enable iw-disconnect.service
        The system will crash on shutdown if firefox is running when starting shutdown, simply close firefox.
		UPDATE; After installing updates (i believe systemd was amongst the list) the wifi shutdown script no longer works for me, so I replaced my shutdown icon with this script;

	#!/bin/bash
	nmcli device disconnect wlan0 &
	/usr/local/bin/closeallapps
	killall /usr/lib/firefox/firefox
	sleep 1.3
	mate-session-save --shutdown-dialog

		THE /usr/local/bin/closeallapps script contains;

	#!/bin/bash
	for n in $(wmctrl -l | awk -v name=$1 '$0 ~ name{print $1}');
	do
	    wmctrl -i -c $n;
	done

    USB;
        sum devices that use too little power will not enumerate, my hack is to add a resistor if possible,
	or use a usb vol/amp meter in-line.
    GTK SLOW WINDOW CREATION;
        The headphone/speakers fix script didnt catch do it manually and they will open fine. No idea the connection.
    LOOSE ABILITY TO RUN su OR sudo (just stalls/sits)
        shutdown with systemctl it doesnt need privlidges
            systemctl poweroff

NOTES;
	If you do have a lock up or shutdown that fails/panics and reboots expect your next 3 boots to be wonky. Most likely
	the wifi or sound wont work then on next boot again one or the other wont work. Sometimes everything will work on the
	first or second boot but it still takes 3 to get normal. Not sure what causes this, if it was leaving hardware is a
	strange state i thought maybe booting windows would set things correct but the one time i tried it didnt.
	Commonly with remoteproc/wifi/etc crashes sudo and su will stop working. Rather then a harsh shutdown
	systemctl poweroff    will shutdown the machine without the need for sudo/su