some configs

fixed?
This commit is contained in:
2024-07-03 15:44:47 -04:00
parent 602a2b2df1
commit 5e13d048d6
89 changed files with 27403 additions and 0 deletions

1
.scripts/add-project Executable file
View File

@@ -0,0 +1 @@
echo "$(pwd) $1" >> ~/.scripts/projects

21
.scripts/bar.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
DATE=$(date +'%Y-%m-%d %I:%M:%S %p')
# BAT=$(cat /sys/class/power_supply/BAT1/capacity)
VOL=$(pactl get-sink-volume @DEFAULT_SINK@ | tr "," "\n" | grep \% | sed s/Volume\:// | sed 's/\%.*$//' | sed 's/^.*\///' | head -n1 | sed s/\ *//)
VOL="${VOL}%"
MUTED=$(pactl get-sink-mute @DEFAULT_SINK@ | cut -d\ -f2)
# BRIGHT=$(brightnessctl | tr "\n" " " | cut -d\ -f9 | tr -d "()%")
MEM=$(free -h | sed 's/[ ]\+/:/g' | cut -d\: -f4 | tr "\n" ":" | cut -d\: -f2)
USER=$(id -u -n)
HOST=$(cat /proc/sys/kernel/hostname)
# LAYOUT=$(swaymsg -t get_inputs | jq -r '.[] | select( .type == "keyboard") .xkb_active_layout_name' | tr "\n" ":" | cut -d\: -f1 | cut -d\ -f2| tr -d "()")
LAYOUT=$(setxkbmap -print -verbose 10 | grep layout | cut -d ":" -f 2 | tr -d " ")
# NETWORK_NAME=$(iwctl station wlan0 show | grep network | sed s/"Connected network"// | tr -d " ")
# IP=$(iwctl station wlan0 show | grep IPv4 | sed s/"IPv4 address"// | tr -d " ")
if [ $MUTED == 'yes' ]
then
VOL='muted'
fi
echo ${MEM} \| ${USER}\@${HOST} \| KB\: ${LAYOUT} \| ${NETWORK_NAME}\@${IP} \| V: ${VOL} \| ${BRIGHT}% Bl \| ${BAT}\% B \| ${DATE}

1
.scripts/build.sh Executable file
View File

@@ -0,0 +1 @@
/usr/lib/jvm/java-11-openjdk/bin/javac -cp ./ $*

1
.scripts/buildtest.sh Executable file
View File

@@ -0,0 +1 @@
/usr/lib/jvm/java-11-openjdk/bin/javac -cp .:/usr/share/java/junit.jar:/usr/share/java/hamcrest/core.jar $*

18206
.scripts/cloc Executable file

File diff suppressed because it is too large Load Diff

5
.scripts/cloc-git Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
git clone --depth 1 "$1" temp-linecount-repo &&
printf "('temp-linecount-repo' will be deleted automatically)\n\n\n" &&
cloc temp-linecount-repo &&
rm -rf temp-linecount-repo

12
.scripts/enter-dev.sh Executable file
View File

@@ -0,0 +1,12 @@
dir="$(cat ~/.scripts/projects | fzf | cut -d\ -f1)"
if [ -z "$dir" ]; then
return
fi
if [ -n "$(command -v tmux)" ] && [ -z "$TMUX" ]; then
tmux new-session -d -c $dir
tmux send-keys -t 0 C-z kak Enter
tmux attach
else
cd $dir
kak
fi

94
.scripts/fzf-ctags Executable file
View File

@@ -0,0 +1,94 @@
#!/usr/bin/env bash
IFS=
# Allow ** glob and Bash extended globbing
shopt -s globstar extglob nullglob
# Set up the template variable.
helper_bin=fzf-ctags-helper
lib_src=fzf-ctags-lib
helper="%FZF_DIR%/bin/$helper_bin"
lib="%FZF_DIR%/bin/$lib_src"
# Setup the colorization preview helper.
if [[ $helper = %*%* ]]; then
# Find the helper if run directly, without installing.
help_dir=${0%/*}
[[ $0 != /* ]] && help_dir=$PWD/$help_dir
lib="$help_dir/$lib_src"
helper=$help_dir/$helper_bin
# Found? Try cat if not.
[[ ! -f $helper ]] && helper=cat
[[ ! -f $lib ]] && {
#printf "Library fzf-ctags-lib not found, exiting.\n"
exit 1
}
fi
# Load shared functions library.
source "$lib"
export FZF_CTAGS_LIB="$lib"
# Which mode? Symbol, or surrounding text?
if [[ $1 == symbol-only ]]; then
q=2
elif [[ -z $1 || $1 = text ]]; then
q=1
fi
typeset tags tags_path ptags="/tmp/.TAGS.z-$$"
get_tags && tags="$REPLY"
# Is there any TAGS file to read?
if [[ -z $tags || ! -f $tags ]]; then
#printf "No \e[38;5;208mTAGS\e[0m file found, exiting…\e[0m\n"
#printf "(\`univeral ctags\` is recommended tool to generate one;\n"
#printf "homepage: https://github.com/universal-ctags/ctags).\n"
exit 1
fi
tags_path="${tags%/TAGS}"
# Sort out the symbol to open at.
type &>/dev/null sed && sed=sed
type &>/dev/null ged && sed=gsed
command $sed -r -n $'/^\x0c$/ { n; s/,[^,]*$//;s/^/\x02/; h; d;}; G; y/\\n/,/; p' "$tags" > "$ptags"
line="$(fzf --preview="printf '%s' {} |$helper" --delimiter '\177' --with-nth $q < <( $sed -r -e 's/^\s+//' \
-e 's/[\x01\x02]/\x7f/g' $ptags ))"
ret=$?
command rm -f $ptags
# Check if anything has been picked.
if (( ret != 0 )) || [[ -z $line ]]; then
printf "\e[38;5;208mNo symbol has been picked out, nothing to do…\e[0m\n"
exit 1
fi
# Split the input.
q=$(cut -d$'\x7f' -f2 <<< $line)
nr=$(cut -d$'\x7f' -f3 <<< $line)
nr=${nr%%,*}
e=$(cut -d$'\x7f' -f4 <<< $line)
# Use the user's configured editor falling back to vim.
ed="${VISUAL:-${EDITOR:-vim}}"
type $ed &>/dev/null || ed=emacs
type $ed &>/dev/null || ed=nano
if ! type $ed &>/dev/null; then
#printf "\e[38;5;208mNo supported editor found, exiting…\e[0m\n"
exit 1
fi
#printf "\nPicked: \e[1;38;5;39m$q\e[0m, opening: \
#\e[1;38;5;70m$ed\e[0m with the file: \e[1;38;5;140m$e\e[0m:\e[38;5;208m$nr\e[0m\n"
# Run editor on the selected file and line.
# The one-time loop is to emphasize the final step.
while
( cd "$tags_path"; command "$ed" +"$nr" "$e"; )
false
do true; done

36
.scripts/fzf-ctags-helper Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Set **/… globs.
shopt -s globstar nullglob extglob
# Load the library of shared functions.
source "$FZF_CTAGS_LIB"
# Prevent word split
IFS=
# Read the line of input.
builtin read -d '' -r q
# Split the input.
p=$(cut -d$'\x7f' -f3 <<< $q)
p=${p%%,*}
e=$(cut -d$'\x7f' -f4 <<< $q)
(( p --, p=p-LINES/2+4, p=p<0?0:p ))
# Preamble,
printf "Showing \e[1;38;5;208m««\e[1;38;5;70m$e\e[0m:\e[1;38;5;33m$p\e[1;38;5;208m»»\e[0m\\n"
eval "printf '—%.0s' {1..$COLUMNS}"
printf "\n"
get_tags && pth=${REPLY%/TAGS} || pth=
(
[[ -n $pth ]] && builtin cd $pth
if [[ -e $e ]]; then
colorize "$p" "$e"
else
printf "File $e not found\n"
fi
)
#less +${p%,*} **/"$e"

51
.scripts/fzf-ctags-lib Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
get_tags() {
local d pth
#PWD=`pwd`
pth=`pwd`
while true; do
[[ -e $pth/TAGS || -z ${pth%/} ]] && break
pth=${pth%/*}
d+=/..
done
[[ -n ${pth#/} ]] && REPLY="$pth"/TAGS
# Explicit!ly testable.
return $?
}
colorize() {
local line="$1" file="$2" lines="$(tput lines 2>/dev/null)"
local sed tool opts end
# Lines to show.
[[ -z $lines ]] && lines="$LINES"
[[ -z $lines ]] && lines=10
((end=line+lines))
# Find sed binary to use.
if type sed &>/dev/null; then
sed=sed
elif type gsed &>/dev/null; then
sed-gsed
else
sed=cat
fi
# Find the tool to use. Prefer pygments for its speed.
if type pygmentize &>/dev/null; then
tool="$sed -e 1,${line}d $file | pygmentize -g | head -n $lines"
opts= file=
elif type pygmentize3 &>/dev/null; then
tool="$sed -e 1,${line}d $file | pygmentize3 -g | head -n $lines"
opts= file=
elif type source-highlight &>/dev/null; then
tool=source-highlight
opts="--line-range=$line-$end -f esc -o STDOUT -i"
else
tool="head -n $end $file | tail -n $lines"
opts= file=
fi
eval "$tool $opts $file"
}

3
.scripts/gb.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
GAMES=$(find /home/mikec/Documents/Games/ROMS/GB -iname "*.zip" | bemenu -i --fn "Cascadia Code 12")
[ -z "$GAMES" ] || mgba "$GAMES"

3
.scripts/gba.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
GAMES=$(find /home/mikec/Documents/Games/ROMS/GBA -iname "*.zip" | bemenu -i --fn "Cascadia Code 12")
[ -z "$GAMES" ] || mgba "$GAMES"

3
.scripts/gbc.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
GAMES=$(find /home/mikec/Documents/Games/ROMS/GBC -iname "*.zip" | bemenu -i --fn "Cascadia Code 12")
[ -z "$GAMES" ] || mgba "$GAMES"

3
.scripts/genesis.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
GAMES=$(find /home/mikec/Documents/Games/ROMS/Genesis -iname "*.zip" | bemenu -i --fn "Cascadia Code 12")
[ -z "$GAMES" ] || blastem "$GAMES"

BIN
.scripts/get_local_path Executable file

Binary file not shown.

17
.scripts/get_local_path.c Normal file
View File

@@ -0,0 +1,17 @@
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main(int argc, char** argv) {
if (argc != 2) {
return -1;
}
bool rel = true;
if (argv[1][1] == '/') {
rel = false;
}
char* last = strrchr(argv[1], '/');
*last = '\0';
puts(argv[1]);
return 0;
}

3
.scripts/n64.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
GAMES=$(find /home/mikec/Documents/Games/ROMS/N64 -iname "*.zip" | bemenu -i --fn "Cascadia Code 12")
[ -z "$GAMES" ] || mupen64plus "$GAMES"

3
.scripts/nes.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
GAMES=$(find /home/mikec/Documents/Games/ROMS/NES/USA -iname "*.nes" | bemenu -i --fn "Cascadia Code 12")
[ -z "$GAMES" ] || fceux "$GAMES"

6
.scripts/open-note.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
FILE=$(rg --no-heading -n . | fzf)
FILEPATH=$(echo $FILE | sed 's/:.*//')
NUMBER=$(echo $FILE | cut -d':' -f2)
kak +$NUMBER $FILEPATH

9
.scripts/projects Normal file
View File

@@ -0,0 +1,9 @@
/home/mikec
/mnt/c/Archive/FB/Product/Cmglobal
/mnt/c/Archive/FB
/mnt/c/Archive
/mnt/c/Archive/Common
/mnt/c/Archive/FB/Core
/mnt/c/Archive/FB/Product
/mnt/c/Archive/FB/Product/Cmglobal/Config
/mnt/c/Users/mchalupi/Documents/Notes

6
.scripts/pws.sh Executable file
View File

@@ -0,0 +1,6 @@
(rg -uu --color=always --line-number --no-heading . > $1) & tail -n +1 -f $1 | \
fzf-tmux --cycle -p 175,45 < /dev/null \
--disabled --ansi \
--bind "change:reload:rg -uu --smart-case {q} $1 || :" \
--bind "enter:become(echo {1} {2})" \
--delimiter : ; pkill -P $$

5
.scripts/remove-project Executable file
View File

@@ -0,0 +1,5 @@
proj="$(cat -n ~/.scripts/projects | fzf | cut -f 1 | tr -d ' ')"
if [ -z "$proj" ]; then
exit
fi
sed -i "$proj"d ~/.scripts/projects

8
.scripts/rfs.sh Executable file
View File

@@ -0,0 +1,8 @@
rg -uu --color=always --line-number --no-heading --smart-case "${*:3}" "$1" | tr -d '\r' |
fzf-tmux --cycle -p 175,45 --ansi \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
--preview "bat --theme='base16-256' --color=always $1 --highlight-line {1}" \
--bind "enter:become(echo \"$2\" '{1}')" \
--preview-window 'right,55%,+{1}+3/3,~3' \

8
.scripts/rfv.sh Executable file
View File

@@ -0,0 +1,8 @@
rg -uu --color=always --line-number --no-heading --smart-case -H "${*:-}" | tr -d '\r' |
fzf-tmux --cycle -p 175,45 --ansi \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
--preview 'bat --theme="base16-256" --color=always {1} --highlight-line {2}' \
--bind 'enter:become(echo "{1}" "{2}")' \
--preview-window 'right,55%,+{2}+3/3,~3' \
#--preview-window 'right,55%' \

8
.scripts/rfve.sh Executable file
View File

@@ -0,0 +1,8 @@
rg --color=always --line-number --no-heading --smart-case "${*:-}" | tr -d '\r' |
fzf-tmux --cycle -p 175,45 --ansi +x -e\
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
--preview 'bat --theme="base16-256" --color=always {1} --highlight-line {2}' \
--bind 'enter:become(echo "{1}" "{2}")' \
--preview-window 'right,55%,+{2}+3/3,~3' \
#--preview-window 'right,55%' \

8
.scripts/rgfs.sh Executable file
View File

@@ -0,0 +1,8 @@
(RELOAD='reload:rg -uu --color=always --line-number --no-heading --smart-case {q} || :'
fzf-tmux --cycle -p 175,45 < /dev/null \
--disabled --ansi \
--bind "start:$RELOAD" --bind "change:$RELOAD" \
--bind "enter:become(echo '{1}' '{2}')" \
--delimiter : \
--preview-window 'right,55%,+{2}+3/3,~3' \
--preview "bat --theme='base16-256' --color=always {1} --highlight-line {2}")

8
.scripts/rgrs.sh Executable file
View File

@@ -0,0 +1,8 @@
(RELOAD="reload:rg -uu --color=always --pcre2 --line-number --no-heading --smart-case {q} $1|| :"
fzf-tmux --cycle -p 175,45 < /dev/null \
--disabled --ansi \
--bind "start:$RELOAD" --bind "change:$RELOAD" \
--bind "enter:become(echo \"$2\" '{1}')" \
--delimiter : \
--preview-window 'right,55%,+{1}+3/3,~3' \
--preview "bat --theme='base16-256' --color=always $1 --highlight-line {1}")

1
.scripts/run.sh Executable file
View File

@@ -0,0 +1 @@
/usr/lib/jvm/java-11-openjdk/bin/java -cp ./ $*

1
.scripts/ryujinx.sh Executable file
View File

@@ -0,0 +1 @@
/opt/ryujinx/Ryujinx.sh

3
.scripts/shutdown.sh Executable file
View File

@@ -0,0 +1,3 @@
#! /bin/sh
killall startup.sh
killall xss-lock

3
.scripts/snes.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
GAMES=$(find /home/mikec/Documents/Games/ROMS/SNES/USA -iname "*.zip" | bemenu -i --fn "Cascadia Code 12")
[ -z "$GAMES" ] || snes9x-gtk "$GAMES"

6
.scripts/startup.sh Executable file
View File

@@ -0,0 +1,6 @@
#! /bin/sh
while true; do
xsetroot -name "$(/home/mikec/.scripts/bar.sh)"
sleep 1
done &
xss-lock -- slock &

470
.scripts/styli.sh Executable file
View File

@@ -0,0 +1,470 @@
#!/usr/bin/env bash
link="https://source.unsplash.com/random/"
if [ -z ${XDG_CONFIG_HOME+x} ]; then
XDG_CONFIG_HOME="${HOME}/.config"
fi
if [ -z ${XDG_HOME+x} ]; then
XDG_HOME="${HOME}"
fi
confdir="${XDG_CONFIG_HOME}/styli.sh"
if [ ! -d "${confdir}" ]; then
mkdir -p "${confdir}"
fi
cachedir="${XDG_HOME}/Pictures/wallpapers"
if [ ! -d "${cachedir}" ]; then
mkdir -p "${cachedir}"
fi
wallpaper="${cachedir}/wallpaper.jpg"
wallpath=""
die() {
printf "ERR: %s\n" "$1" >&2
exit 1
}
# https://github.com/egeesin/alacritty-color-export
alacritty_change() {
DEFAULT_MACOS_CONFIG="$HOME"/.config/alacritty/alacritty.yml
# Wal generates a shell script that defines color0..color15
SRC="$HOME"/.cache/wal/colors.sh
[ -e "$SRC" ] || die "Wal colors not found, exiting script. Have you executed Wal before?"
printf "Colors found, source ready.\n"
READLINK=$( command -v greadlink || command -v readlink )
# Get config file
if [ -n "$1" ]; then
[ -e "$1" ] || die "Selected config doesn't exist, exiting script."
printf "Config found, destination ready.\n"
CFG=$1
[ -L "$1" ] && {
printf "Following symlink to config...\n"
CFG=$($READLINK -f "$1")
}
else
# Default config path in Mac systems
[ -e "$DEFAULT_MACOS_CONFIG" ] || die "Alacritty config not found, exiting script."
CFG="$DEFAULT_MACOS_CONFIG"
[ -L "$DEFAULT_MACOS_CONFIG" ] && {
printf "Following symlink to config...\n"
CFG=$($READLINK -f "$DEFAULT_MACOS_CONFIG")
}
fi
# Get hex colors from Wal cache
# No need for shellcheck to check this, it comes from pywal
# shellcheck disable=SC1090
. "$SRC"
# Create temp file for sed results
tempfile=$(mktemp)
trap 'rm $tempfile' INT TERM EXIT
# Delete existing color declarations generated by this script
# If begin comment exists
if grep -q '^# BEGIN ACE' "$CFG"; then
# And if end comment exists
if grep -q '^# END ACE' "$CFG"; then
# Delete contents of the block
printf "Existing generated colors found, replacing new colors...\n"
sed '/^# BEGIN ACE/,/^# END ACE/ {
/^# BEGIN ACE/! { /^# END ACE/!d; }
}' "$CFG" > "$tempfile" \
&& cat "$tempfile" > "$CFG"
# If no end comment, don't do anything
else
die "No '# END ACE' comment found, please ensure it is present."
fi
# If no begin comment found
else
# Don't do anything and notify user if there's an end comment in the file
! grep -q '^# END ACE' "$CFG" || die "Found '# END ACE' comment, but no '# BEGIN ACE' comment found. Please ensure it is present."
printf "There's no existing 'generated' colors, adding comments...\n";
printf '# BEGIN ACE\n# END ACE' >> "$CFG";
fi
# Write new color definitions
# We know $colorX is unset, we set it by sourcing above
# shellcheck disable=SC2154
{ sed "/^# BEGIN ACE/ r /dev/stdin" "$CFG" > "$tempfile" <<EOP
colors:
primary:
background: '$color0'
foreground: '$color7'
cursor:
text: '$color0'
cursor: '$color7'
normal:
black: '$color0'
red: '$color1'
green: '$color2'
yellow: '$color3'
blue: '$color4'
magenta: '$color5'
cyan: '$color6'
white: '$color7'
bright:
black: '$color8'
red: '$color9'
green: '$color10'
yellow: '$color11'
blue: '$color12'
magenta: '$color13'
cyan: '$color14'
white: '$color15'
EOP
} && cat "$tempfile" > "$CFG" \
&& rm "$tempfile"
trap - INT TERM EXIT
printf "'%s' exported to '%s'\n" "$SRC" "$CFG"
}
reddit(){
useragent="thevinter"
timeout=60
sort=$2
top_time=$3
if [ -z $sort ]; then
sort="hot"
fi
if [ -z $top_time ]; then
top_time=""
fi
if [ ! -z $1 ]; then
sub=$1
else
if [ ! -f "${confdir}/subreddits" ]; then
echo "Please install the subreddits file in ${confdir}"
exit 2
fi
readarray subreddits < "${confdir}/subreddits"
a=${#subreddits[@]}
b=$(($RANDOM % $a))
sub=${subreddits[$b]}
sub="$(echo -e "${sub}" | tr -d '[:space:]')"
fi
url="https://www.reddit.com/r/$sub/$sort/.json?raw_json=1&t=$top_time"
content=`wget -T $timeout -U "$useragent" -q -O - $url`
urls=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.preview.images[0].source.url')
names=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.title')
ids=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.id')
arrURLS=($urls)
arrNAMES=($names)
arrIDS=($ids)
wait # prevent spawning too many processes
size=${#arrURLS[@]}
if [ $size -eq 0 ]; then
echo The current subreddit is not valid.
exit 1
fi
idx=$(($RANDOM % $size))
target_url=${arrURLS[$idx]}
target_name=${arrNAMES[$idx]}
target_id=${arrIDS[$idx]}
ext=`echo -n "${target_url##*.}"|cut -d '?' -f 1`
newname=`echo $target_name | sed "s/^\///;s/\// /g"`_"$subreddit"_$target_id.$ext
wget -T $timeout -U "$useragent" --no-check-certificate -q -P down -O ${wallpaper} $target_url &>/dev/null
}
unsplash() {
local search="${search// /_}"
if [ ! -z $height ] || [ ! -z $width ]; then
link="${link}${width}x${height}";
else
link="${link}1920x1080";
fi
if [ ! -z $search ]; then
link="${link}/?${search}"
fi
wget -q -O ${wallpaper} $link
}
deviantart(){
client_id=16531
client_secret=68c00f3d0ceab95b0fac638b33a3368e
payload="grant_type=client_credentials&client_id=${client_id}&client_secret=${client_secret}"
access_token=`curl --silent -d $payload https://www.deviantart.com/oauth2/token | jq -r '.access_token'`
if [ ! -z $1 ]; then
artist=$1
url="https://www.deviantart.com/api/v1/oauth2/gallery/?username=${artist}&mode=popular&limit=24"
elif [ ! -z $search ]; then
[[ "$search" =~ ^(tag:)(.*)$ ]] && tag=${BASH_REMATCH[2]}
if [ ! -z $tag ]; then
url="https://www.deviantart.com/api/v1/oauth2/browse/tags?tag=$tag&offset=${RANDOM:0:2}&limit=24"
else
url="https://www.deviantart.com/api/v1/oauth2/browse/popular?q=$search&limit=24&timerange=1month"
fi
else
#url="https://www.deviantart.com/api/v1/oauth2/browse/hot?limit=24&offset=${offset}"
topics=( "adoptables" "artisan-crafts" "anthro" "comics" "drawings-and-paintings" "fan-art" "poetry" "stock-images" "sculpture" "science-fiction" "traditional-art" "street-photography" "street-art" "pixel-art" "wallpaper" "digital-art" "photo-manipulation" "science-fiction" "fractal" "game-art" "fantasy" "3d" "drawings-and-paintings" "game-art" )
rand=$[$RANDOM % ${#topics[@]}]
url="https://www.deviantart.com/api/v1/oauth2/browse/topic?limit=24&topic=${topics[$rand]}"
fi
content=`curl --silent -H "Authorization: Bearer ${access_token}" -H "Accept: application/json" -H "Content-Type: application/json" $url`
urls=$(echo -n $content | jq -r '.results[].content.src')
arrURLS=($urls)
size=${#arrURLS[@]}
idx=$(($RANDOM % $size))
target_url=${arrURLS[$idx]}
wget --no-check-certificate -q -P down -O ${wallpaper} $target_url &>/dev/null
}
usage(){
echo "Usage: styli.sh [-s | --search <string>]
[-h | --height <height>]
[-w | --width <width>]
[-b | --fehbg <feh bg opt>]
[-c | --fehopt <feh opt>]
[-a | --artist <deviant artist>]
[-r | --subreddit <subreddit>]
[-l | --link <source>]
[-p | --termcolor]
[-d | --directory]
[-k | --kde]
[-x | --xfce]
[-g | --gnome]
[-m | --monitors <monitor count (nitrogen)>]
[-n | --nitrogen]
"
exit 2
}
type_check() {
mime_types=("image/bmp" "image/jpeg" "image/gif" "image/png" "image/heic")
isType=false
for requiredType in "${mime_types[@]}"
do
if [ $dir ]; then
imageType=$(file --mime-type "$HOME/Pictures/wallpaper_dump/${wallpaper}" | sed 's/.*image/image/')
echo $imageType
if [ "$requiredType" = "$imageType" ]; then
isType=true
break
fi
else
imageType=$(file --mime-type ${wallpaper} | awk '{print $2}')
if [ "$requiredType" = "$imageType" ]; then
isType=true
break
fi
fi
done
if [ $isType = false ]; then
echo "MIME-Type missmatch. Downloaded file is not an image!"
exit 1
fi
}
select_random_wallpaper () {
wallpaper=$(ls $HOME/Pictures/wallpaper_dump | shuf -n 1)
}
pywal_cmd() {
if [ $pywal -eq 1 ]; then
wal -c
wal -i ${wallpaper} -n -q
if [ $TERM = alacritty ]; then
alacritty_change
fi
fi
}
sway_cmd() {
mode="fill"
if [ ! -z $dir ]; then
cp "$HOME/Pictures/wallpaper_dump/${wallpaper}" "$HOME/Pictures/wallpapers/wallpaper"
swaymsg output "*" bg "$HOME/Pictures/wallpaper_dump/${wallpaper}" "${mode}"
else
swaymsg output "*" bg "${wallpaper}" "${mode}"
fi
}
nitrogen_cmd() {
for ((monitor=0; monitor < $monitors; monitor++))
do
local nitrogen=(nitrogen --save --head=${monitor})
if [ ! -z $bgtype ]; then
if [ $bgtype == 'bg-center' ]; then
nitrogen+=(--set-centered)
fi
if [ $bgtype == 'bg-fill' ]; then
nitrogen+=(--set-zoom-fill)
fi
if [ $bgtype == 'bg-max' ]; then
nitrogen+=(--set-zoom)
fi
if [ $bgtype == 'bg-scale' ]; then
nitrogen+=(--set-scaled)
fi
if [ $bgtype == 'bg-tile' ]; then
nitrogen+=(--set-tiled)
fi
else
nitrogen+=(--set-scaled)
fi
if [ ! -z $custom ]; then
nitrogen+=($custom)
fi
nitrogen+=(${wallpaper})
"${nitrogen[@]}"
done
}
kde_cmd() {
if [ ! -z $dir ]; then
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file:$HOME/Pictures/wallpaper_dump/${wallpaper}\")}"
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file:$HOME/Pictures/wallpaper_dump/${wallpaper}\")}"
else
cp ${wallpaper} "${cachedir}/tmp.jpg"
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file:${cachedir}/tmp.jpg\")}"
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file:${wallpaper}\")}"
rm "${cachedir}/tmp.jpg"
fi
}
xfce_cmd() {
connectedOutputs=$(xrandr | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
activeOutput=$(xrandr | grep -e " connected [^(]" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
connected=$(echo $connectedOutputs | wc -w)
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -n -t string -s ~/Pictures/1.jpeg
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorLVDS1/workspace0/last-image -n -t string -s ~/Pictures/1.jpeg
for i in $(xfconf-query -c xfce4-desktop -p /backdrop -l|egrep -e "screen.*/monitor.*image-path$" -e "screen.*/monitor.*/last-image$"); do
xfconf-query -c xfce4-desktop -p $i -n -t string -s ${wallpaper}
xfconf-query -c xfce4-desktop -p $i -s ${wallpaper}
done
}
gnome_cmd() {
if [ ! -z $dir ]; then
gsettings set org.gnome.desktop.background picture-uri "file://$HOME/Pictures/wallpaper_dump/${wallpaper}"
gsettings set org.gnome.desktop.background picture-uri-dark "file://$HOME/Pictures/wallpaper_dump/${wallpaper}"
else
gsettings set org.gnome.desktop.background picture-uri "file://${wallpaper}"
gsettings set org.gnome.desktop.background picture-uri-dark "file://${wallpaper}"
fi
}
feh_cmd() {
local feh=(feh)
if [ ! -z $bgtype ]; then
if [ $bgtype == 'bg-center' ]; then
feh+=(--bg-center)
fi
if [ $bgtype == 'bg-fill' ]; then
feh+=(--bg-fill)
fi
if [ $bgtype == 'bg-max' ]; then
feh+=(--bg-max)
fi
if [ $bgtype == 'bg-scale' ]; then
feh+=(--bg-scale)
fi
if [ $bgtype == 'bg-tile' ]; then
feh+=(--bg-tile)
fi
else
feh+=(--bg-scale)
fi
if [ ! -z $custom ]; then
feh+=($custom)
fi
if [ ! -z $dir ]; then
cp "$HOME/Pictures/wallpaper_dump/${wallpaper}" "$HOME/Pictures/wallpapers/wallpaper"
feh+=("$HOME/Pictures/wallpaper_dump/${wallpaper}")
else
feh+=(${wallpaper})
fi
"${feh[@]}"
}
pywal=0
kde=false
xfce=false
gnome=false
nitrogen=false
sway=false
monitors=1
PARSED_ARGUMENTS=$(getopt -a -n $0 -o h:w:s:l:b:r:a:c:d:m:pknxgy --long search:,height:,width:,fehbg:,fehopt:,artist:,subreddit:,directory:,monitors:,termcolor:,kde,nitrogen,xfce,gnome,sway -- "$@")
VALID_ARGUMENTS=$?
if [ "$VALID_ARGUMENTS" != "0" ]; then
usage
exit
fi
while :
do
case "${1}" in
-b | --fehbg) bgtype=${2} ; shift 2 ;;
-s | --search) search=${2} ; shift 2 ;;
-h | --height) height=${2} ; shift 2 ;;
-w | --width) width=${2} ; shift 2 ;;
-l | --link) link=${2} ; shift 2 ;;
-r | --subreddit) sub=${2} ; shift 2 ;;
-a | --artist) artist=${2} ; shift 2 ;;
-c | --fehopt) custom=${2} ; shift 2 ;;
-m | --monitors) monitors=${2} ; shift 2 ;;
-n | --nitrogen) nitrogen=true ; shift ;;
-d | --directory) dir=${2} ; shift 2 ;;
-p | --termcolor) pywal=1 ; shift ;;
-k | --kde) kde=true ; shift ;;
-x | --xfce) xfce=true ; shift ;;
-g | --gnome) gnome=true ; shift ;;
-y | --sway) sway=true ; shift ;;
-- | '') shift; break ;;
*) echo "Unexpected option: $1 - this should not happen." ; usage ;;
esac
done
if [ ! -z $dir ]; then
select_random_wallpaper
elif [ $link = "reddit" ] || [ ! -z $sub ]; then
reddit "$sub"
elif [ $link = "deviantart" ] || [ ! -z $artist ]; then
deviantart "$artist"
else
unsplash
fi
echo $dir
type_check
if [ $kde = true ]; then
kde_cmd
elif [ $xfce = true ]; then
xfce_cmd
elif [ $gnome = true ]; then
gnome_cmd
elif [ $nitrogen = true ]; then
nitrogen_cmd
elif [ $sway = true ]; then
sway_cmd
else
feh_cmd
fi
pywal_cmd

1
.scripts/test.sh Executable file
View File

@@ -0,0 +1 @@
/usr/lib/jvm/java-11-openjdk/bin/java -cp .:/usr/share/java/junit.jar:/usr/share/java/hamcrest/core.jar org.junit.runner.JUnitCore $*