Add some custom scripts

This commit is contained in:
ItsDrike 2021-01-28 12:47:32 +01:00
parent edc7a37a1e
commit 63c6f643a9
No known key found for this signature in database
GPG key ID: 252D306F545351FC
6 changed files with 129 additions and 0 deletions

View file

@ -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 '<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Sans</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Serif</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Noto Mono</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Sans Mono</family>
</prefer>
</alias>
</fontconfig>
' > /etc/fonts/local.conf
# Update font cache
fc-cache -f
echo "Noto Emoji Font installed! You will need to restart application to see changes."

7
home/.local/scripts/fixcam.sh Executable file
View file

@ -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

View file

@ -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

View file

@ -0,0 +1,7 @@
#!/bin/bash
# Uninstall the virtual microphone.
pactl unload-module module-pipe-source
rm $HOME/.config/pulse/client.conf

BIN
home/.local/scripts/usbreset Executable file

Binary file not shown.

View file

@ -0,0 +1,40 @@
/* usbreset -- send a USB port reset to a USB device */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
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;
}