if [ -f ~/.bash_aliases_priv ]; then . ~/.bash_aliases_priv fi alias weston-phone="weston --width=1920 --height=1056 -S /run/user/1000/wayland-1" alias waydroid-start="waydroid session start" alias waydroid-show="waydroid show-full-ui" alias waydroid-stop="waydroid session stop" alias waydroid-launch="weston-phone && waydroid-start & read && waydroid-stop" alias show-waydroid="waydroid-show" alias swd="waydroid-show" alias launch-waydroid="waydroid-launch" alias screen-off="xset dpms force off" alias boot-sign-verify="sudo sign-boot && sudo verify-boot" function kernel-build-dep() { echo "[+] Kernel Build Dependancy Installation..."; sudo apt install gawk git dh-make llvm libclang-dev libclang1 sbsigntool; sudo apt build-dep linux-image-unsigned-$(uname -r); } function kernel-build() { echo "[+] Kernel Build Starting..."; cwd=$(pwd); mkdir -p ~/kernel; cd ~/kernel; for _dir in *"linux"*; do [ -d "${_dir}" ] && linuxdir="${_dir}" && break; done; echo "[-] Removing Sources..."; rm -rf "$linuxdir"; sudo rm -rf deb-contents; rm -f *.gz; rm -f *.dsc; echo "[*] Archiving old packages..."; mkdir -p old-debs; touch dummy.deb; mv *.deb old-debs/; echo "[+] Obtaining Sources..."; apt-get source linux-image-unsigned-$(uname -r); for _dir in *"linux"*; do [ -d "${_dir}" ] && linuxdir="${_dir}" && break; done; cd "$linuxdir"; echo "[*] Patching source and configuration..."; sed -i "s/.*CONFIG_MODULE_SIG_FORCE.*/CONFIG_MODULE_SIG_FORCE policy<{'amd64': 'y', 'arm64': 'y', 'armhf': 'y', 'ppc64el': 'y', 's390x': 'y'}>/" debian.master/config/annotations; git apply --verbose ~/Downloads/patches/hibernate/0001-Hibernate-Patch.patch; echo "[*] Cleaning kernel build..."; chmod a+x debian/rules; chmod a+x debian/scripts/*; chmod a+x debian/scripts/misc/*; fakeroot debian/rules clean; mkdir -p debian/build/build-generic/certs; sudo cp /cert/mok/signing_key.pem ../; sudo chmod u=rw,g=rw,o=rw ../signing_key.pem; (((until [ -f debian/build/build-generic/certs/signing_key.pem ]; do sleep 0.1; done) && while lsof debian/build/build-generic/certs/signing_key.pem; do sleep 0.1; done) && mv -f ../signing_key.pem debian/build/build-generic/certs/signing_key.pem) & echo "[*] Building kernel..."; fakeroot debian/rules binary; echo "[*] Build Complete!"; rm -f debian/build/build-generic/certs/signing_key.pem; rm -f ../signing_key.pem; echo "[+] Extracting kernel package..."; cd ~/kernel; mkdir -p deb-contents; dpkg-deb -R $(ls linux-image-unsigned-* | head -1) deb-contents; cd "$linuxdir"; echo "[*] Making kernel signed..."; pkgarch=$(dpkg-architecture -qDEB_HOST_ARCH); pkgver=$(dpkg-parsechangelog --show-field Version); cd ~/kernel/deb-contents; pkgunom=$(head -1 DEBIAN/control | sed -e 's/Package: //'); find ./ -type f -exec sed -i -e 's/-unsigned//g' {} \; find ./ -type f -exec sed -i -e 's/ unsigned//g' {} \; pkgnom=$(head -1 DEBIAN/control | sed -e 's/Package: //'); sudo mv usr/share/doc/$pkgunom usr/share/doc/$pkgnom; tlinuz=$(ls boot/vmlinuz-* | head -1); sudo sbsign --key /cert/BMOK.priv --cert /cert/BMOK.pem $tlinuz --output $tlinuz; sed -i "s/.*Conflicts: .*/Conflicts: $pkgunom/" DEBIAN/control; pkgisz=$(du -ks * | grep -v DEBIAN | cut -f1 | xargs | sed -e 's/\ /+/g' | bc); find ./ -path '*/DEBIAN' -prune -o -type f -exec md5sum {} \; | awk '{ print $1 " " substr($2, 10) }' > DEBIAN/md5sums; sed -i "s/.*Installed-Size: .*/Installed-Size: $pkgisz/" DEBIAN/control; echo "[+] Packing signed kernel..."; cd ~/kernel; dpkg-deb -b deb-contents ${pkgnom}_${pkgver}_${pkgarch}.deb; sudo rm -rf deb-contents; echo "[+] Deploying Packages Locally..."; sudo cp ${pkgnom}_${pkgver}_${pkgarch}.deb /usr/local/mydebs/; sudo cp linux-headers-* /usr/local/mydebs/; sudo cp linux-libc-dev* /usr/local/mydebs/; sudo cp linux-modules* /usr/local/mydebs/; sudo update-mydebs; cd "$cwd"; echo "Kernel Build Finished!"; } function install-tar() { if [ $# -gt 0 ]; then if [ $# -eq 1 ]; then fln=$(basename -- "$1"); flp=$1; else fln=$(basename -- "$2"); flp=$2; fi fln="${fln%%.*}"; echo "Installing: /opt/$fln"; sudo mkdir -p "/opt/$fln"; sudo tar -xvf "$flp" -C /opt/$fln; if [ $# -gt 1 ]; then sudo chown -R "$1" /opt/$fln; fi else echo "Usage:"; echo "install-tar | "; fi } function install-tar-contents() { if [ $# -gt 0 ]; then if [ $# -eq 1 ]; then flp=$1; else flp=$2; fi echo "Installing: /opt"; sudo tar -xvf "$flp" -C /opt; if [ $# -gt 1 ]; then sudo chown -R "$1" /opt; fi else echo "Usage:"; echo "install-tar-contents | "; fi } function edit-dot-desktop() { sudo nano "/usr/share/applications/$(basename -- "$1").desktop"; } function edit-dot-desktop-local() { nano ~"/.local/share/applications/$(basename -- "$1").desktop"; } function tpm2-contents() { sudo tpm2_selftest sudo tpm2_gettestresult sudo tpm2_getcap -l sudo tmp2_pcrread sudo tpm2_pcrread } alias list-xinput-devices="xinput list" function disable-xinput-device() { if [ -z $1 ]; then echo "Provide a device name fragment."; else cdid=$(xinput list | grep "$1" | head -1 | grep -Po 'id=\K[^\t]*' | head -1); echo "Disabling: $cdid"; xinput disable $cdid; fi; } function enable-xinput-device() { if [ -z $1 ]; then echo "Provide a device name fragment."; else cdid=$(xinput list | grep "$1" | head -1 | grep -Po 'id=\K[^\t]*' | head -1); echo "Enabling: $cdid"; xinput enable $cdid; fi; } function record-screen-x11() { cwd=$(pwd); cd ~/Videos; mkdir -p ScreenRecordings; cd ScreenRecordings; srecfname="recording_"$(date '+%Y-%m-%d_%H-%M-%S')".mkv"; if [ $# -gt 0 ]; then srecintv="$1"; if [ $# -gt 1 ]; then srecfname="$2"; fi else srecintv='1'; fi echo "Recording x11 screen to ${srecfname} every ${srecintv}s at 30 fps."; ffmpeg -framerate "$srecintv" -f x11grab -s 1920,1080 -i :0.0+0,0 -vf settb=\(1/30\),setpts=N/TB/30 -r 30 -vcodec libx264 -crf 0 -preset ultrafast -threads 0 "$srecfname"; cd "$cwd"; }