degoogle: Add the script

This script will convert WebP to PNG and WebM to MP4. Added custom
action for Thunar as well.
This commit is contained in:
Harzo 2023-05-27 22:18:48 +02:00
parent 34f61bfc58
commit 0adb282700
2 changed files with 43 additions and 0 deletions

View File

@ -12,4 +12,16 @@
<startup-notify/> <startup-notify/>
<directories/> <directories/>
</action> </action>
<action>
<icon>gtk-convert</icon>
<name>Degoogle</name>
<submenu></submenu>
<unique-id>1685216951025684-1</unique-id>
<command>~/.scripts/degoogle %F</command>
<description>Convert WebP and WebM to PNG and MP4 respectively</description>
<range>*</range>
<patterns>*.webp;*.webm</patterns>
<image-files/>
<video-files/>
</action>
</actions> </actions>

31
.scripts/degoogle Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env fish
for filename in $argv
switch $filename
case '*.webp'
set -l basename (basename $filename)
set -l dirname (dirname $filename)
set -l rootname (echo $basename | string split -f 1 -m 1 -r .)
set targetname "$dirname/$rootname.png"
set attempt 0
while test $attempt -le 200
if test -f $targetname
set attempt (math $attempt + 1)
set targetname "$dirname/$rootname-$attempt.png"
continue
end
convert "$filename" "$targetname"
break
end
case '*.webm'
set -l basename (basename $filename)
set -l dirname (dirname $filename)
set -l rootname (echo $basename | string split -f 1 -m 1 -r .)
set -l targetname "$dirname/$rootname.mp4"
ffmpeg -i $filename -c:v libx264 -crf 24 $targetname
case '*'
echo "Neither webp nor webm, skipping."
end
end