From 63c6f643a9fabc2567e4cee022f35de75f307d76 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 28 Jan 2021 12:47:32 +0100 Subject: [PATCH] Add some custom scripts --- home/.local/scripts/emoji-font-setup.sh | 54 +++++++++++++++++++++++ home/.local/scripts/fixcam.sh | 7 +++ home/.local/scripts/install_virtmic.sh | 21 +++++++++ home/.local/scripts/uninstall_virtmic.sh | 7 +++ home/.local/scripts/usbreset | Bin 0 -> 16960 bytes home/.local/scripts/usbreset.c | 40 +++++++++++++++++ 6 files changed, 129 insertions(+) create mode 100755 home/.local/scripts/emoji-font-setup.sh create mode 100755 home/.local/scripts/fixcam.sh create mode 100755 home/.local/scripts/install_virtmic.sh create mode 100755 home/.local/scripts/uninstall_virtmic.sh create mode 100755 home/.local/scripts/usbreset create mode 100644 home/.local/scripts/usbreset.c diff --git a/home/.local/scripts/emoji-font-setup.sh b/home/.local/scripts/emoji-font-setup.sh new file mode 100755 index 0000000..f49891f --- /dev/null +++ b/home/.local/scripts/emoji-font-setup.sh @@ -0,0 +1,54 @@ +#!/bin/sh +set -e +if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi + +echo "Setting up Noto Emoji font..." +# Install noto-fonts-emoji repository as the basic emoji font +pacman -S noto-fonts-emoji --needed +# Install powerline-fonts for powerline statusline +pacman -S powerline-fonts --needed +echo "Font packages installed, setting up font-config" +# Make sure noto emojis are preferred font /etc/fonts/local.conf +# another way to do this would be to manually figure out the number and use /etc/fonts/conf.d/01-notosans.conf +# note that the `01` might be too agressive and override other fonts, it is therefore easier to just use `local.conf` +# if you still want to use the manual numbered representation, make sure to store the file into /etc/fonts/conf.avail/XX-notosans.conf +# from which you will then make a symlink pointing to /etc/fonts/conf.d (same name) +echo ' + + + + sans-serif + + Noto Sans + Noto Color Emoji + Noto Emoji + DejaVu Sans + + + + + serif + + Noto Serif + Noto Color Emoji + Noto Emoji + DejaVu Serif + + + + + monospace + + Noto Mono + Noto Color Emoji + Noto Emoji + DejaVu Sans Mono + + + + +' > /etc/fonts/local.conf +# Update font cache +fc-cache -f +echo "Noto Emoji Font installed! You will need to restart application to see changes." + diff --git a/home/.local/scripts/fixcam.sh b/home/.local/scripts/fixcam.sh new file mode 100755 index 0000000..2e44874 --- /dev/null +++ b/home/.local/scripts/fixcam.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Fix camera autofocus and exposure +v4l2-ctl -d /dev/video0 --set-ctrl=focus_auto=0 +v4l2-ctl -d /dev/video0 --set-ctrl=exposure_auto=3 +v4l2-ctl -d /dev/video0 --set-ctrl=sharpness=150 +v4l2-ctl -d /dev/video0 --set-ctrl=exposure_auto_priority=0 diff --git a/home/.local/scripts/install_virtmic.sh b/home/.local/scripts/install_virtmic.sh new file mode 100755 index 0000000..9d3493d --- /dev/null +++ b/home/.local/scripts/install_virtmic.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# This script will create a virtual microphone for PulseAudio to use and set it as the default device. + +# Load the "module-pipe-source" module to read audio data from a FIFO special file. +echo "Creating virtual microphone." +pactl load-module module-pipe-source source_name=virtmic file=$HOME/.config/pulse/audioFiles/virtmic format=s16le rate=16000 channels=1 + +# Set the virtmic as the default source device. +echo "Set the virtual microphone as the default device." +pactl set-default-source virtmic + +# Create a file that will set the default source device to virtmic for all +PulseAudio client applications. +echo "default-source = virtmic" > $HOME/.config/pulse/client.conf + +# Write the audio file to the named pipe virtmic. This will block until the named pipe is read. +echo "Writing audio file to virtual microphone." +while true; do + ffmpeg -re -i input.wav -f s16le -ar 16000 -ac 1 - > $HOME/.config/pulse/audioFiles/virtmic +done diff --git a/home/.local/scripts/uninstall_virtmic.sh b/home/.local/scripts/uninstall_virtmic.sh new file mode 100755 index 0000000..c178f5f --- /dev/null +++ b/home/.local/scripts/uninstall_virtmic.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Uninstall the virtual microphone. + +pactl unload-module module-pipe-source +rm $HOME/.config/pulse/client.conf + diff --git a/home/.local/scripts/usbreset b/home/.local/scripts/usbreset new file mode 100755 index 0000000000000000000000000000000000000000..56d2f9fdf869693ff9983c83cbba386be4f5700d GIT binary patch literal 16960 zcmeHOUu+yl8K3jTiPJV`$4!W78nP{^4xum#eH`RhOA0NQ zV=Z+Eg^~58_6(^Oq6{A)0~AKLA9ZE6MXJSYyBEjxaX+Gw{YWIg1?{(>{TOF-dyJe< z$_afg>UibY2^|$ivZd1Zx|5*#!v;x9ahswABl{hIpH8*5_-Np?AJpwt%S)5)KchZe zu{D((Y}>Xqm1s#N)A{k1@$GFbZQH`RO!y9Y+-uN0ox(l)2E_jEv)R;_fB(XX(PcYR zO|R@~dHcY9)Nkqo#UmRkWY6g*T!jzm<#DNorJDF1@0{YH2x)2gJSbx+E$I9-R^TaS zC4PMszPSqDQH4JV-oU54gh5nlmkzfQe@hkqTi^|R%FCS~ZY?Jv)A?B~n#9qFQu4SJ zV|F&1$%?VOlM`dvWZD@LIVS;9Br|a*C59f%CLLSEQ<gnHWA+SB1%sFU(F2&PWrE|w+#>Km@&si70f{lUmF8+EKzu@9;aPfTp=w3==m`hVc z)hIUQgNqSSHRAOxRuauFp6@B7Xm#=OeoZ9G_J{;QaX1&mL?ZMpB#%UwiWyN=vcImx z`V~I|eg^yu_!;ms;Ag^_){vykt&Yth*qSQ@ra{ z(8b$c!*~702x=sckZx|Kh;rM@B-114+$AahmSlPaoI5Aw=SikVzqu!+{0zzT$TxRJ z%1@C@k9u>brTjCJ>Cts=5;FDg_P_NMUOZwJUNxs)oA2xIovv*|d~p+_=^0U1Ljow_i2V@7G8H&nWx&{ zgHT+18sD>V9L%$|S5XZdzAzN7-*|$$AubFp)+xUfZ*Ca21BihWV-$|RVHWZ;Q^((^ zakii*KSl(zaQ-O+&QDX?aRj?UXyBP^#o}3c9)3vdsjeCGRHV)4q49hF z;phX=!_gyA%bjCtk48439QUP>PRHdJKLdUS{0#UR@H60Nz|Vl60Y3wN2K)^C|7IYd z-_{J|V#D^`Mm{%~wR5&(Bd=nHZ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iaVXAoyD=@ZSJmaX(9JFxisMICeOW zT_q4KCpIjS>7)Z9o^^6g9xJ}$VsRsi<&0X`-IBI*a7bjV;Z$ZYma-B~CY!Tj`Ee1? zjE<#j$4=nKv!Vs~Yj- zFhiG-XF6<;=;1q(fGKj{9OXn$W9dg#6^%Sk*R1R-*9i;wxcv?7$2dtwu2L3W zd=omi{~2w-IKYX~G1#9&ez(k@=P!)>e+agxT)WE|2-JS583O_pLw<{g6_ma?|4dMR z-TpiuVx)J+?o!_V&!Ket^Sp_X&p*c~Z~q(=SR5^{0kYxeVBQ~HZqG8~3-G~HTFIaP z|1#e~(H6&xk``t5r~c8{;b}6@*LeT=3>_Q_k1zJ)^Y|y|$b|iQUUykP=rxnGtFS-g zpP_U6i-)TQqaP^0#> zd5LF#{g_HkvPcj>6V`aZ2HKPn5(?XoRB RW>@lme}}RNmN}G(;@_YD4*dWC literal 0 HcmV?d00001 diff --git a/home/.local/scripts/usbreset.c b/home/.local/scripts/usbreset.c new file mode 100644 index 0000000..76c30c0 --- /dev/null +++ b/home/.local/scripts/usbreset.c @@ -0,0 +1,40 @@ +/* usbreset -- send a USB port reset to a USB device */ + +#include +#include +#include +#include +#include + +#include + + +int main(int argc, char **argv) +{ + const char *filename; + int fd; + int rc; + + if (argc != 2) { + fprintf(stderr, "Usage: usbreset device-filename\n"); + return 1; + } + filename = argv[1]; + + fd = open(filename, O_WRONLY); + if (fd < 0) { + perror("Error opening output file"); + return 1; + } + + printf("Resetting USB device %s\n", filename); + rc = ioctl(fd, USBDEVFS_RESET, 0); + if (rc < 0) { + perror("Error in ioctl"); + return 1; + } + printf("Reset successful\n"); + + close(fd); + return 0; +}