From 94778c70b8a4396fbee25d7653fa0830803b6d32 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 7 Jan 2023 14:36:59 +0200 Subject: Squashed '.local/bin/scripts/' changes from f797a45..0e48d67 0e48d67 Removed st in favour of alacritty 03be387 Add killandnotify script 966087e Add ffmpeg script f0ca2dd Add colors script git-subtree-dir: .local/bin/scripts git-subtree-split: 0e48d677ccf014c65c1fbb0bc4690737325df678 --- Heads-Up-Display | 2 +- colors.sh | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ffmpeg | 24 +++++++++++++++++ killandnotify | 4 +++ 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100755 colors.sh create mode 100755 ffmpeg create mode 100755 killandnotify diff --git a/Heads-Up-Display b/Heads-Up-Display index cac8681..d90c7d3 100755 --- a/Heads-Up-Display +++ b/Heads-Up-Display @@ -2,7 +2,7 @@ id=$(xdotool search --class Heads-Up-Display); if [ -z "$id" ]; then - st -c Heads-Up-Display -e tmux attach -t HUD || tmux new -s HUD; + alacritty --class "Heads-Up-Display" -e tmux new-session -A -s HUD -e bash > /dev/null 2>&1 & else if [ ! -f /tmp/hide_hud ]; then touch /tmp/hide_hud && xdo hide "$id" diff --git a/colors.sh b/colors.sh new file mode 100755 index 0000000..fc1c10c --- /dev/null +++ b/colors.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +colors=$@ +for (( n=0; n < $colors; n++ )) do + printf " [%d] $(tput setaf $n)%s$(tput sgr0)" $n "Hello World! +" +done +PADDING='Padding' + +main() { + local xterm_start=0 \ + xterm_width=8 \ + xterm_height=2 + + local cube_start=$((xterm_start + xterm_width * xterm_height)) \ + cube_width=6 \ + cube_height=$((6 * 6)) + + local greys_start=$((cube_start + cube_width * cube_height)) \ + greys_width=8 \ + greys_height=3 + + color_block $xterm_start $xterm_width $xterm_height + color_block $cube_start $cube_width $cube_height use_padding + color_block $greys_start $greys_width $greys_height + echo +} + +color_block() { + local start=$1 width=$2 height=$3 use_padding=$4 + local max s color_nums colors + + max=$((start + width * height - 1)) + + echo + for s in $(seq $start $width $max); do + color_nums=$(seq $s $((s + width - 1))) + colors="${use_padding:+$PADDING }${color_nums}${use_padding:+ $PADDING}" + + printf '%s%s %s%s\n' \ + "$(fg_bars $colors)" $ansi_reset \ + "$(bg_bars $colors)" $ansi_reset + done +} + +fg_bars() { + for color in $@; do + color_bar ansi_fg $color '' + done +} + +bg_bars() { + for color in $@; do + color_bar ansi_bg $color ' ' + done +} + +color_bar() { + local ansi=$1 color=$2 trail=$3 + + if [ "$color" == $PADDING ]; then + printf '%s %s' $ansi_reset "$trail" + else + local color_seq=$($ansi $color) + printf '%s %03d%s' $color_seq $color "$trail" + fi +} + +ansi_reset=$'\033[0m' + +ansi_fg() { + printf '\033[38;5;%dm' $1 +} + +ansi_bg() { + printf '\033[48;5;%dm' $1 +} + +main diff --git a/ffmpeg b/ffmpeg new file mode 100755 index 0000000..2258fbd --- /dev/null +++ b/ffmpeg @@ -0,0 +1,24 @@ +#!/bin/bash + +# audio +A="$(pactl list sources | grep 'analog.*monitor' | awk '{print $2}')" +# screen size +S="$(xdpyinfo | grep dimensions | awk '{print $2}')" +# file name +N="$(date +"%m-%d-%Y_%I:%M%p").mp4" + +# Desktop audio + screen recording +ffmpeg \ +-s "$S" -r 25 -f x11grab -i :0.0+0,0 \ +-ac 2 ~/"$N" + +# ffmpeg can output high quality GIF. Before you start it is always recommended to use a recent version: download or compile. + +# ffmpeg -ss 30 -t 3 -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif + +# This example will skip the first 30 seconds (-ss 30) of the input and create a 3 second output (-t 3). +# fps filter sets the frame rate. A rate of 10 frames per second is used in the example. +# scale filter will resize the output to 320 pixels wide and automatically determine the height while preserving the aspect ratio. The lanczos scaling algorithm is used in this example. +# palettegen and paletteuse filters will generate and use a custom palette generated from your input. These filters have many options, so refer to the links for a list of all available options and values. Also see the Advanced options section below. +# split filter will allow everything to be done in one command and avoids having to create a temporary PNG file of the palette. +# Control looping with -loop output option but the values are confusing. A value of 0 is infinite looping, -1 is no looping, and 1 will loop once meaning it will play twice. So a value of 10 will cause the GIF to play 11 times. diff --git a/killandnotify b/killandnotify new file mode 100755 index 0000000..2e7222e --- /dev/null +++ b/killandnotify @@ -0,0 +1,4 @@ +#!/bin/sh +# Kills an application and sends a notification that it's been killed + +killall "$1" && notify-send "$1" "$2" -- cgit v1.2.3