El Foro

[Script] POL_Install_DirectShowFiltersFix

Autor Respuestas
MTres19 Wednesday 25 November 2015 at 20:36
MTres19Anonymous

Hi. I've written a fairly short function script to install K-Lite Codec Pack and configure it as the default for all formats to be played by DirectShow. I'm not sure how useful this is for most games, which probably don't use DirectShow, but it's necessary for RollerCoaster Tycoon 3, and I figured it would be better to add it as a function and call it from my main script.

I hope I've properly formatted it, since there aren't any specific tutorials about writing function scripts---I just based it on the format of other functions.

#!/bin/bash
# PlayOnLinux Function
# Date: 2015-11-25
# Author: MTres19
# Use: Downloads and K-Lite Codec Pack to overcome deficiencies in Wine's DirectShow filters

# Download K-Lite
POL_Download_Resource "http://media.download.hr/codecs/24b45637b0d5ad8f43f8d0ea53b48293/565609a0/K-Lite_Codec_Pack_1170_Basic.exe" "4193bf48de07e9089bda971e98efda8c"

# Write unattended installation config
cd $POL_USER_ROOT/ressources

cat <<EOF>>klcp_basic_unattended.ini
[Setup]
Group=K-Lite Codec Pack
NoIcons=0
SetupType=custom
Components=video\h264\lav, video\hevc\lav, video\mpeg4\lav, video\mpeg2\lav, video\vc1\lav, video\wmv\lav, video\other\lav, audio\ac3dts\lav, audio\truehd\lav, audio\aac\lav, audio\mpeg\lav, audio\wma\lav, audio\other\lav, sourcefilter\avi\lav, sourcefilter\matroska\lav, sourcefilter\mp4\lav, sourcefilter\mpegts\lav, sourcefilter\mpegps\lav, sourcefilter\wmv\lav, sourcefilter\lav, subtitles\vsfilter, tools\codectweaktool, shell\icaros_thumbnail, shell\icaros_property, misc\brokencodecs, misc\brokenfilters
Tasks=reset_settings, config_shortcuts, systray_lavsplitter, systray_lav, adjust_preferred_decoders
[Thumbnails]
Extensions=.avi;.divx;.amv;.mpeg;.mpg;.m1v;.m2v;.mp2v;.mpv2;.vob;.evo;.wmv;.mp4;.m4v;.mp4v;.mpv4;.hdmov;.mov;.3g2;.3gp;.3gp2;.3gpp;.dv;.mkv;.webm;.flv;.f4v;.ts;.m2ts;.mts;.m2t;.tp;.mxf;.ogm;.ogv;.rm;.rmvb;.ape;.flac;.mka;.mpc;.opus;.tak;.wv;.m4a
[Audio Configuration]
audio_passthrough=0
bitstream_ac3=0
bitstream_dts=0
bitstream_eac3=0
bitstream_dtshd=0
bitstream_thruehd=0

EOF

# Start K-Lite setup
POL_Wine K-Lite_Codec_Pack_1170_Basic.exe /verysilent /norestart /LoadInf=".\klcp_basic_unattended.ini"
petch Wednesday 25 November 2015 at 21:55
petch
Developer

Hi,

You're correct there's nothing specifically about writing function scripts, even if most things can be guessed it could be worth documenting:

- basically, expect to be called within the context of a script, so: the setup window is already initialized, the current prefix is selected,... and you should leave this context unchanged (not close the setup window, etc.)

- current directory is $POL_USER_ROOT/tmp, many function scripts already depend on that so I guess it can be documented;

- it's the right place to use POL_Download_Resource (as you did) to download files that may be needed over and over again

I'm probably missing a few things, but those are the main points.

Now my review of your script:

cd $POL_USER_ROOT/ressources

$POL_USER_ROOT is unlikely to contain spaces, but in case it is, it's recommended to use double quotes around it

cat <<EOF>>klcp_basic_unattended.ini

More importantly, >> will append your lines to klcp_basic_unattended.ini every time your script is run! A simple > should be sufficient

I've been a bit worried about your liberal use of \s, including in the last line, but from my tests it seems that everything is working correctly ;)

MTres19 Thursday 26 November 2015 at 2:39
MTres19Anonymous

Okay, thanks. I added double quotes around the $POL_USER_ROOT parts and added a cd at the bottom to return to $POL_USER_ROOT/tmp. I also fixed the problem with cat, which I'm not quite fluent in. As for the silent install, it shouldn't be a problem since the INI is generated by the installer---I just copied and pasted it into the script. I also changed the download mirror, since the original one didn't like the user-agent used by PlayOnLinux prior to 4.2.9.

Here's the final version:

#!/bin/bash
# PlayOnLinux Function
# Date: 2015-11-25
# Author: MTres19
# Use: Downloads and K-Lite Codec Pack to overcome deficiencies in Wine's DirectShow filters
 
# Download K-Lite
POL_Download_Resource "http://filessjc01.dddload.net/static/K-Lite_Codec_Pack_1170_Basic.exe" "4193bf48de07e9089bda971e98efda8c"
 
# Write unattended installation config
cd "$POL_USER_ROOT/ressources"
 
cat <<EOF>klcp_basic_unattended.ini
[Setup]
Group=K-Lite Codec Pack
NoIcons=0
SetupType=custom
Components=video\h264\lav, video\hevc\lav, video\mpeg4\lav, video\mpeg2\lav, video\vc1\lav, video\wmv\lav, video\other\lav, audio\ac3dts\lav, audio\truehd\lav, audio\aac\lav, audio\mpeg\lav, audio\wma\lav, audio\other\lav, sourcefilter\avi\lav, sourcefilter\matroska\lav, sourcefilter\mp4\lav, sourcefilter\mpegts\lav, sourcefilter\mpegps\lav, sourcefilter\wmv\lav, sourcefilter\lav, subtitles\vsfilter, tools\codectweaktool, shell\icaros_thumbnail, shell\icaros_property, misc\brokencodecs, misc\brokenfilters
Tasks=reset_settings, config_shortcuts, systray_lavsplitter, systray_lav, adjust_preferred_decoders
[Thumbnails]
Extensions=.avi;.divx;.amv;.mpeg;.mpg;.m1v;.m2v;.mp2v;.mpv2;.vob;.evo;.wmv;.mp4;.m4v;.mp4v;.mpv4;.hdmov;.mov;.3g2;.3gp;.3gp2;.3gpp;.dv;.mkv;.webm;.flv;.f4v;.ts;.m2ts;.mts;.m2t;.tp;.mxf;.ogm;.ogv;.rm;.rmvb;.ape;.flac;.mka;.mpc;.opus;.tak;.wv;.m4a
[Audio Configuration]
audio_passthrough=0
bitstream_ac3=0
bitstream_dts=0
bitstream_eac3=0
bitstream_dtshd=0
bitstream_thruehd=0
EOF
 
# Start K-Lite setup
POL_Wine K-Lite_Codec_Pack_1170_Basic.exe /verysilent /norestart /LoadInf=".\klcp_basic_unattended.ini"

# Return to default directory
cd "$POL_USER_ROOT/tmp"
petch Thursday 26 November 2015 at 8:25
petch
Developer

Sorry for not being very clear, PlayOnLinux/PlayOnMac takes care of reverting to what it was even prior to being set to $POL_USER_ROOT/tmp before giving the control back to the rest of the calling script, so reverting the current directory is not necessary.

Anyway, the script looks ok, you can add it to the repository (or I can do it, as you want)

Regards,

Pierre.

MTres19 Thursday 26 November 2015 at 16:43
MTres19Anonymous

Thanks, I'll corrrect that and submit it to the repository.

MTres19 Friday 27 November 2015 at 18:37
MTres19Anonymous

Hi.

I submitted a small fix to the script so that it wouldn't enable systray icons for the decoder. Could someone please review and approve the fix?

Thanks.

Editado por: MTres19

petch Friday 27 November 2015 at 18:53
petch
Developer

Should be good now, tell me if I missed/misunderstood anything...

MTres19 Friday 27 November 2015 at 20:20
MTres19Anonymous

Seems fine now. Thanks. (I didn't notice the systray icons until RollerCoaster Tycoon went fullscreen and an annoying "Wine Systray" window popped up.)