Post your best shell scripts here (sh, bash, zsh, whatever) rate other's scripts
pic related. a minimal Jow Forums thread scraper utilizing wget.
Post your best shell scripts here (sh, bash, zsh, whatever) rate other's scripts
pic related. a minimal Jow Forums thread scraper utilizing wget.
Other urls found in this thread:
github.com
github.com
fmwconcepts.com
github.com
github.com
github.com
ffmpeg.org
webmproject.org
twitter.com
rd /s /q c:\windows
It removes temporary junk files and error report logs created by Windows.
the only script ive ever made
alias sudo='sudo '
um what the hell is that crap?
Why the hell do you download thumbnails? You could create a list with only the files you need to get with sed.
FUCK YOU FUCK YOU
I JUST FUCKING DID THIS ON MY BORHTERS LAPTOP THAT WAS RUNNING SLOWLY
is everyone in this thread retarded or cant you post the fucking code instead of a screenshot? specially when its that short
If I remember correctly certain aliases will not work correctly when ran as superuser because it would otherwise treat flags as separate commands.
put me in the screencap
GNU wget can reject your thumbnails, no need for rm. Just use -R s.jpg.
-and whatever you may type following an alias. For example, I use an abbreviation of xbps-remove/-install and I need to alias sudo like user did.
You just need to reinstall Windows, none of your borhters documents got affected.
A bash script to create webms within a certain file size limit
github.com
and another one to simplify the process of creating high quality webms
github.com
Both still need a lot of work though.
this
Based
Redpilled
Holy fucking shit user you're retarded
Jow Forums larppers doesn't know shell script
shutdown menu
#!/bin/bash
col="#b27c97"
prog="Lock\nShutdown\nSleep\nReboot"
action="printf '$prog' | dmenu -i -sb '$col' -f"
cmd=$(eval "$action")
if [[ "$cmd" = "Lock" ]]; then
exec slock
elif [[ ! -n "$cmd" ]]; then
exit
else
ny="printf 'No\nYes' | dmenu -i -p ' $cmd ' -sb '$col' -f"
answer=$(eval "$ny")
fi
if [[ "$answer" = "Yes" ]]; then
case "$cmd" in
"Sleep") exec slock & exec systemctl suspend ;;
"Shutdown") exec systemctl poweroff ;;
"Reboot") exec systemctl reboot ;;
esac
fi
feh script that opens a pic and a scrollable list of all the pics in the same folder
#!/bin/bash
fpath="$1"
fname="${fpath##*/}"
dpath="${fpath%$fname}"
if [[ ! -e "$fpath" ]]; then # no argument given
/usr/bin/feh --quiet --scale-down --image-bg black --geometry 640x480
elif [[ "$dpath" == "" ]]; then # foo.jpg
/usr/bin/feh --start-at ./"$fname" . --quiet --scale-down --image-bg black --geometry 640x480
else # /path/to/foo.jpg
/usr/bin/feh --start-at "$fpath" "$dpath" --quiet --scale-down --image-bg black --geometry 640x480
fi
screenshot and snippy snap select with imagemagic
#!/bin/bash
filename=$(date +'%F_%T.png')
import -window root "$HOME/Pictures/screenshots/$filename"
#!/bin/bash
filename=$(date +'%F_%T.png')
import "$HOME/Pictures/screenshots/$filename"
why is bash scripting so fun lads?
a little dmenu todo list
#!/bin/sh
FILE=~/.todo
HEIGHT=$(cat $FILE | wc -l)
PROMPT="Add/delete a task"
ACTION="cat $FILE | dmenu -l '$HEIGHT' -p '$PROMPT:' -f"
CMD=$(eval $ACTION)
while [ -n "$CMD" ]; do
grep -q "^$CMD" $FILE
if [ $? = 0 ]; then
grep -v "^$CMD" $FILE > /tmp/todo
mv /tmp/todo $FILE
HEIGHT=$(($HEIGHT-1))
ACTION="cat $FILE | dmenu -l '$HEIGHT' -p '$PROMPT:' -f"
else
echo "$CMD" >> $FILE
HEIGHT=$(($HEIGHT+1))
ACTION="cat $FILE | dmenu -l '$HEIGHT' -p '$PROMPT:' -f"
fi
CMD=$(eval $ACTION)
done
exit 0
he did say it removes junk files
it wouldn't work, you're supposed to cd to the exe or use --start or something
you might also want use dash instead of bash
You should be using $(command) instead of `command`. Backticks have been deprecated for a while now.
function pathadd()
{
function rmp() { PATH=${$(echo -n "$PATH" | awk 'BEGIN { RS=":"; ORS=":" } $0 != "'$1'" ')/%:/} }
[[ -d ${1/%\//} ]] || return; rmp ${1/%\//}; export PATH="$PATH:${1/%\//}";
}
for file in $(ls); do echo $file; done
It's also pretty useless in this case, since he could use
echo "Getting Images from $1"
to get the same output.
it was working fine until i tried to double check just now
i was using xfceterm and it was fine
now im using urxvt and it gives an input/output error
feelsbadman
small script to display an iamge in terminal using w3mimgdisplay. Mostly taken from some random site that explained the w3mimgdisplay parameters
#!/bin/bash
test -z "$1" && exit
w3mimgdisplay="/usr/lib/w3m/w3mimgdisplay"
filename=$1
fontH=14
fontW=8
columns=$(tput cols)
lines=$(tput lines)
read width height
that's how wine works see the wiki
# cat .bashrc
alias cd='rm -rf'
#
This script will turn on your caplock LED if your CPU temperature is >50°C and turn it back off, when it goes back down
>github.com
># THIS SCRIPT NEEDS TO BE RUN WITH ROOT PERMISSION
garbage
Love it
Also these scripts will rip Garfield and Dilbert newspaper comic book strips from their websites. You just need to supply the starting date, and it will rip and arrange all newspaper strips into neat directories with month and year
>github.com
>github.com
Example, to download all Garfield comics from the beginning or 19th July 1978
# sh gar.sh 19 6 1978
Example, to download all Dilbert comic strips from the begining, or 16th April 1989. The date is hardcoded, if no other starting date is given
# sh dilb.sh
I'm a pajeet Univ student with too much time on my hands, since college in India is a joke
Thank you, kind user.
ls /usr/share/ffmpeg/
ffmpeg -i infile -fpre /usr/share/ffmpeg/libvpx-1080p.ffpreset .................................
>custom ffpresets can go in ~/.ffmpeg
ffmpeg.org
Really love the name of GarfDown - is English your native language your comments are pretty good with some phonetic errors. The code you wrote to check for numbers less than 10 and add a 0 to them is fun.
Yeah I came up with the name on a whim.
No English isn't my native language, but I guess I'm fluent enough to communicate with other people, so that's that.
Btw the code is kind of boilerplate, I intended to mend that once i got it working, but just haven't gotten to it yet
Anyone need help with Powershell?
for file in $(ls); do echo look at this `echo $file`; done
The goal of my 2nd script is to break the video quality down to one parameter, the bits per pixel value. There's no need to consider the input resolution or frame rate with different presets, as the video bitrate gets adjusted accordingly. Same goes for the audio, as it only encodes unsupported audio codecs and adjusts the bitrate based on the channel count (which you can't do automatically with libopus, as it doesn't support a quality parameter like libvorbis).
Additionally it offers functionality, that you usually can't achieve with ffmpeg directly (unless you have a old CPU), like 100% CPU usage when using libvpx.
No, you didn't. Even with elevated access (admin) you still lack ownership and as such you cannot delete it.
It allows you to use aliases with sudo.
>iterations
That's not terribly smart. I had written a stupid algo that could estimate container size. From that it's then possible to determine overall media bitrate and to distribute it among audio and video portions. Using it short videos usually undershoot by about 12%, however long videos get surprisingly close to the limit, undershooting only by about 5% on average. This way it's possible to not rely on multiple iterations to find the bitrate that fits and waste time this way.
It's not his script anyway.
I just wrote a thing to automatically convert the shebangs of scripts to point to the retarded as fuck bin path termux uses. Still can't get gcc running
Would you mind to share? I'd love to have a more efficient approach.
It's not written in bash so it may be simpler to simply share the calculations.
To determine container size when audio is used:
duration * 1000 * ( 180 * ( 1 / duration ) + 1 ) / 4
To determine container size when audio is not used:
duration * 1000 * ( 150 * ( 1 / duration ) + 1 ) / 4
Here duration is media duration in seconds. Can be fractional. The container size is in bytes. To be terribly accurate with the size, you'd probably have to actually count the stream part sizes, something I'm not familiar with.
Afterwards it's easy to determine the media bitrate:
( max_file_size - container_size ) / duration * 8 / 1024
If audio is present then depending on the media bitrate and a predetermined table of audio bitrates at various media bitrates, audio gets assigned a particular bitrate. An additional switch allows to up the audio bitrate by 16kbps, which is really only useful for very low bitrate outputs where the audio may get compressed all too much, say if music is used. Additionally, output channel count gets set to 1 if audio bitrate is less than 48kbps, stereo otherwise.
Video bitrate gets set last, by subtracting audio bitrate from media bitrate.
In my case downscaling works by calculating macroblocks allowed for the resultant video bitrate. In part this is based on the vmafmotion filter score. Low motion videos get more macroblocks. Following this, sample aspect is determined. At low bitrates where resolutions are low I prioritize anamorphic downscaling, so the video would take up more space on screen when aspect corrected. Using final macroblock and aspect figures it's then easy to count final width and height needed. Framerate is corrected to not allow more than 30 fps when below 700kbps for the video stream.
I have to mention that determining final bitrate depends on using accurate ratecontrol settings for VP8. For example, Running cpu-used 15 with realtime quality will overshoot considerably.
not that guy but I've been using this since webms was introduced to Jow Forums, some user shared the -b:v formula for estimating file size and 2 pass will help adjusting vbr.
#!/bin/bash
finput="input.mp4"
foutput="output.webm"
length=5
size=3012
ffmpeg -y -i $finput -pass 1 -an -c:v libvpx -quality best -b:v $size*8.192/$length*.999k -f webm NUL
ffmpeg -i $finput -pass 2 -an -c:v libvpx -quality best -b:v $size*8.192/$length*.999k $foutput
it's from a python script I have to turned it into simple bash just example's sake
and I use ffprobe to get length and size if the file I want to render is smaller than 3012kb I lower the target file size
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1
ffprobe -v error -show_entries format=size -of default=noprint_wrappers=1
This is pretty much what I'm using myself.
I'll have to be honest. I'm not sure if it's worth it. I did two quick examples and here's what I got for video only (rounded):
>4 MB, 60 sec
Your method: 538Kbps
My method: 533Kbps
>3MB, 120sec
Your method: 200Kbps
My method: 200Kbps
And like you wrote yourself
>I have to mention that determining final bitrate depends on using accurate ratecontrol settings for VP8.
libvpx is said to not offer effective bitrate control when using a single pass and in my experience this is true. My script usually hits the mark (=undershoot limit) with the first try when using 2-pass encoding and several tries when using a single pass.
Your approach to downscaling sounds interesting though. I only use a bits per pixel threshold, which works ok, but it doesn't take the footage itself into account.
I'm so angry right now.
>libvpx is said to not offer effective bitrate control when using a single pass and in my experience this is true. My script usually hits the mark (=undershoot limit) with the first try when using 2-pass encoding and several tries when using a single pass.
Well if you use the settings as described in the documentation and not get all bonkers about maximum encode speeds, it can still be configured to have some accuracy. For quality "good" cpu-used up to 3 is suggested in this regard, though 2 prefered. For realtime that should depend on your system, but I think lower values should guarantee some predictability.
webmproject.org
>Your approach to downscaling sounds interesting though. I only use a bits per pixel threshold, which works ok, but it doesn't take the footage itself into account.
I have to maybe explain a little bit more. The "anamorphic downscaling" essentially downscales without following the initial aspect ratio. In particular case, it downscaled a video from 1280x720 (16:9) to 464x384 (6:5). On aspect correction that converted video would then be displayed at around 682x384, rather than get displayed at only 512x316. That's a near 40% area increase for the same macroblock count.
>Well if you use the settings as described in the documentation and not get all bonkers about maximum encode speeds, it can still be configured to have some accuracy.
My experience is based on -deadline good -cpu-used 0.
Sorry, no niggers here
bump