initial commit

This commit is contained in:
celso 2023-03-24 14:40:17 -03:00
commit 9a0a747dc0
16 changed files with 208 additions and 0 deletions

7
brightness.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
printf "%s" "${1}" | grep "^-\?[0-9.]\+$">/dev/null || exit 1
curval="$(xrandr --verbose | grep -o "Brightness: [0-9.]\+" | grep -o "[0-9.]\+")"
[ $(bc -l <<< "scale=1;${curval}>=0.3") -eq 1 ] &&\
[ $(bc -l <<< "scale=1;${curval}<=2") -eq 1 ]\
&& curval="$(bc -l <<< "scale=1;${curval}+${1}")"
xrandr --output LVDS1 --brightness "${curval}"

2
prtscr/prtscra.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
import -window root -quality 00 png:- | xclip -selection clipboard -t image/png

2
prtscr/prtscrcr.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
import -window $(xprop -root _NET_ACTIVE_WINDOW | awk '{print $5}') -quality 00 png:- | xclip -selection clipboard -t image/png

2
prtscr/prtscrsel.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
import -quality 00 png:- | xclip -selection clipboard -t image/png

3
screc/audiorec.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
ffmpeg -loglevel error -threads 4 -f alsa -probesize 10M -channels 2 -sample_rate 48000 -thread_queue_size 2048 -i default /tmp/raw.wav

14
screc/fbufferrec.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
fps="25"
bitrate="3000k"
read -p 'type in filename >' filename
if [ -z "$filename" ];
then
filename="test"
fi
#ffmpeg -hide_banner -threads 4 -f fbdev -i /dev/fb0 /tmp/$filename
ffmpeg -hide_banner -threads:0 3 -threads:1 1 \
-f fbdev -probesize 42M -framerate $fps -thread_queue_size 1024 -i /dev/fb0 \
-f alsa -probesize 10M -channels 2 -sample_rate 48000 -thread_queue_size 1024 -i default \
-c:v libopenh264 -allow_skip_frames true -b:v $bitrate \
-c:a aac -af asetpts=N/SR/TB /tmp/$filename.mp4

14
screc/screenrecord.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
inres="1366x768"
fps="25"
bitrate="3000k"
read -p 'type in filename >' filename
if [ -z "$filename" ];
then
filename="test"
fi
ffmpeg -threads:0 3 -threads:1 1 \
-f x11grab -probesize 42M -video_size $inres -framerate $fps -thread_queue_size 1024 -i :0.0 \
-f alsa -probesize 10M -channels 2 -sample_rate 48000 -thread_queue_size 1024 -i default \
-c:v libopenh264 -allow_skip_frames true -b:v $bitrate \
-c:a aac -af asetpts=N/SR/TB /tmp/$filename.mp4

13
screc/screenrecordnoa.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
inres="1366x768"
fps="30"
bitrate="3000k"
read -p 'type in filename >' filename
if [ -z "$filename" ];
then
filename="test"
fi
ffmpeg -hide_banner -threads:0 3 -threads:1 1 \
-f x11grab -probesize 42M -video_size $inres -framerate $fps -thread_queue_size 1024 -i :0.0 \
-c:v libopenh264 -allow_skip_frames true -b:v $bitrate \
/tmp/$filename.mp4

10
sleepytime.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
usagemsg="usage: sleepytime.sh [time in seconds]\n%7ssleepytime.sh resume\n\nrequires read/write \
access to /tmp\nmake sure you only have one video player open or only the first one will be paused!\n"
pid=$(ps -aux | awk '{print $11" "$2}' | grep -m 1 "^mpv\|^vlc" | grep -o "[0-9]*")
printf "%d" "${pid}" > /tmp/sleepytime_pid
[ "$1" == "resume" ] && kill -SIGCONT $(cat /tmp/sleepytime_pid) && rm /tmp/sleepytime_pid && exit 0
printf "%d" "$1" 1>/dev/null 2>&1; [ "${?}" != 0 ] && printf "error: not a number\n${usagemsg}" && exit 2
sleepytime="${1:-1800}"
target_time=$(expr $(date +%s) + "${sleepytime}" );
while [ $(date +%s) -le "${target_time}" ]; do sleep 10; done; kill -SIGTSTP "${pid}"

28
speedstep.py Normal file
View File

@ -0,0 +1,28 @@
import os
import subprocess
import time
# available frequency steps: 2.53 GHz, 2.39 GHz, 2.26 GHz, 2.13 GHz, 2.00 GHz, 1.86 GHz, 1.73 GHz, 1.60 GHz, 1.46 GHz, 931 MHz
actual_values=["2.53GHz", "2.40GHz", "2.27GHz", "2.13GHz", "2.00GHz", "1.87GHz", "1.73GHz", "1.60GHz", "1.47GHz", "931MHz"]
steps=["2.53GHz", "2,39GHz", "2.26GHz", "2.13GHz", "2.00GHz", "1.86GHz", "1.73GHz", "1.60GHz", "1.46GHz", "931MHz"]
curstep=0
# the command to change max frequency is cpupower frequency-set -u states.get(key)
# the command to get current freq is sudo cpupower frequency-info -wm | awk '{print $4}' | grep "\S"
while True:
# step down as long as temp is above 82ºC
if int(subprocess.getoutput('cat /sys/class/thermal/thermal_zone0/temp'))>=82000 and subprocess.getoutput('sudo cpupower frequency-info -wm | awk \'{print $4 $5}\' | grep "\S"')!=steps[9]:
curstep=curstep+1
print("changing frequency to %s" % steps[curstep])
os.system('sudo cpupower frequency-set -u %s' % actual_values[curstep])
#subprocess.run('sudo cpupower frequency-set -u %s' % actual_values[curstep])
time.sleep(1)
# step up as long as temp is below 70ºC
if int(subprocess.getoutput('cat /sys/class/thermal/thermal_zone0/temp'))<=70000 and subprocess.getoutput('sudo cpupower frequency-info -wm | awk \'{print $4 $5}\' | grep "\S"')!=steps[0]:
curstep=curstep-1
print("changing frequency to %s" % steps[curstep])
os.system('sudo cpupower frequency-set -u %s' % actual_values[curstep])
#subprocess.run('sudo cpupower frequency-set -u %s' % actual_values[curstep])
time.sleep(1)
# wait a second before completing loop
time.sleep(1)

2
streams.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
streamlink $(xclip -selection clipboard -o) || mpv $(xclip -selection clipboard -o)

29
twitch/gettwurl.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# twitch api credentials
client_id="ib8heiflx9p0u12j9p5wybh6wjnhn2"
client_secret="u3ieq39z3e7lo1ewb69l9oueexxe2l"
grant_type="client_credentials"
# get access token
access_token=$(curl -s -X POST https://id.twitch.tv/oauth2/token -d "client_id=$client_id" -d "client_secret=$client_secret" -d "grant_type=$grant_type" | awk -F '[\"\"|:|,]' '{print $5}')
read -p 'type in username >' login
# get user id
user_id=$(curl -s -X GET "https://api.twitch.tv/helix/users?login=$login" -H "Authorization: Bearer $access_token" -H "client-id: $client_id" | awk -F '[\"\"|:|,]' '{print $8}')
# save json with first page of results for videos tied to the user id we just got
curl -s -X GET "https://api.twitch.tv/helix/videos?user_id=$user_id" -H "Authorization: Bearer $access_token" -H "client-id: $client_id" > /tmp/streamarchives.txt
# loop through the json
range=$(grep -Po "url\":\"[a-zA-Z0-9 \\+|\!#\$@.\-\[\]{}=,*/<>_:'()]+\"" /tmp/streamarchives.txt | awk 'BEGIN {FS="\""} END{print NR}')
for x in $(eval echo "{1..$range}"); do
titles=$(echo -e $(cat /tmp/streamarchives.txt) | grep -Po "title\":\"[a-zA-Z0-9 %\\+|\!#\$@.\-\[\]{}=,*/<>_:'()]+\"" | awk -v x=$x 'BEGIN{FS="\""} FNR==x {print $3}')
url=$(grep -Po "url\":\"[a-zA-Z0-9 \\+|\!#\$@.\-\[\]{}=,*/<>_:'()]+\"" /tmp/streamarchives.txt | awk -v x=$x 'BEGIN{FS="\""} FNR==x {print $3}')
duration=$(grep -Po "duration\":\"[a-zA-Z0-9 %\\+|\!#\$@.\-\[\]{}=,*/<>_:'()]+\"" /tmp/streamarchives.txt | awk -v x=$x 'BEGIN{FS="\""} FNR==x {print $3}')
#echo "$url $duration $titles"
echo "$x $titles $duration" >> /tmp/titles.txt
done
#read -p "choose a vid for clipboard or leave empty to quit >" choice
choice=$(cat /tmp/titles.txt | dmenu -c -l 10 -bw 3 | awk '{print $1}') && rm /tmp/titles.txt
[ -z $choice ] && exit || grep -Po "url\":\"[a-zA-Z0-9 \\+|\!#\$@.\-\[\]{}=,*/<>_:'()]+\"" /tmp/streamarchives.txt | awk -v choice=$choice 'BEGIN {FS="\""} FNR==choice {print $3}' | xclip -r -selection clipboard && rm /tmp/streamarchives.txt

31
twitch/twitch-getvideo.py Normal file
View File

@ -0,0 +1,31 @@
from requests import *
import os
def titles(jsonwithids):
"""gets the value of the key 'title' of the first 5 items in the json dict, adds them to a list and returns that list"""
titles=[]
durations=[]
for x in range(5):
titles.append(jsonwithids[x].get('title'))
durations.append(jsonwithids[x].get('duration'))
return titles, durations
def choice(titles, durations):
"""prints the titles and prompts the user to choose one, returns the choice as a number from 0 to 4"""
for x in range(5):
print(titles[x], durations[x])
choice=int(input('Type a number from 1 to 5 to choose video >'))-1
return choice
def main():
"""runs the program"""
params1={'client_id':'ib8heiflx9p0u12j9p5wybh6wjnhn2', 'client_secret':'u3ieq39z3e7lo1ewb69l9oueexxe2l', 'grant_type':'client_credentials'}
access_token=post('https://id.twitch.tv/oauth2/token', params=params1).json().get('access_token')
heads={'Authorization':'Bearer %s'% access_token,'client-id':params1.get('client_id')}
user_id=get('https://api.twitch.tv/helix/users', params={'login':input('Type in the channel name >')}, headers=heads).json().get('data')[0].get('id')
lastvideos=get('https://api.twitch.tv/helix/videos', params={'user_id':user_id}, headers=heads).json().get('data')
a,b=titles(lastvideos)
os.system('streamlink '+lastvideos[choice(a,b)].get('url')+'?t='+input('Type time in xhxmxs format (optional)>')+' 720p60,720p')
if __name__ == '__main__':
main()

12
xsetroot/sysstatus.sh Executable file
View File

@ -0,0 +1,12 @@
clear
while true; do
curtime=$(date +%T)
curdate=$(date +'%a %d/%m')
curtemp=$(bc -l <<< "scale = 1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000")
curfreq=$(sudo cpupower frequency-info -wm | awk {'print $4 $5'} | grep "\S")
curram=$(free -h | grep Mem | awk '{print $3"/"$2}')
status="$curram - $curtempºC - @$curfreq - $curdate $curtime"
printf "%s" "${status}"
for (( i=0; i<="${#status}"; i++ )) ; do printf "\b"; done
sleep 1
done

5
xsetroot/wallpaper.sh Executable file
View File

@ -0,0 +1,5 @@
#! /bin/bash
while :;do
feh --bg-max --randomize /home/celso/.config/wallpapers/
sleep 3600
done

34
xsetroot/xsetroot.sh Executable file
View File

@ -0,0 +1,34 @@
## ICONS FOR FUTURE VERSION
##  wi fi
while true; do
curtime="$(date +%T)"
curtimeicon=""
curdate="$(date +'%a %d/%m')"
curtemp="$(bc -l <<< "scale = 1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000")"
curfreq="$(bc -l <<< "scale=2; ($(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq) + 5000) / 1000000")"
vol="$(amixer get Master)"
curvol=$(awk '{FS="[][]"} {print $2}' <<< "${vol}" | grep -o "[0-9]*")
curvolstatus=$(awk '{FS="[][]"} {print $6}' <<< "${vol}" | grep "\S")
curram="$(free -h | grep Mem | awk '{print $3"/"$2}')"
curramicon=""
mhz="$(bc -l <<< "${curfreq} < 1")"
if [ ${mhz} -eq 1 ]; then
curfreq="$(printf "%0.f\n" $(bc -l <<< "0.93 * 1000"))"
curfreq_suffix="MHz"
else
curfreq_suffix="GHz"
fi
if [ $curvol -ge 51 ]; then
curvolicon=""
elif [ $curvol -lt 51 ] && [ $curvol -gt 0 ]; then
curvolicon=""
else
curvolicon=""
fi
if [ $curvolstatus != "on" ]; then
curvolicon=""
fi
rootname="${curramicon} ${curram} - ${curtemp}º - @${curfreq} ${curfreq_suffix} - ${curvolicon} ${curvol}% - ${curdate} ${curtimeicon} ${curtime}"
xsetroot -name "${rootname}"
sleep 0.9
done