+
     Gi  c                   s    ^ RI Ht ^RIHt ^ RIt^ RIt^ RIHtH	t	 ]P                  P                  4       t ! R R]P                  4      tR# )i    N)base)PopenPIPEc                   s   a a ] tR t^	t oRt]R 4       tR tR tR t	V 3R lt
V 3R lt]P                  3V 3R lltR	tVtV ;t# )
ScriptPlugina  
Executes an external script or binary when the profile is loaded or
unloaded. You can choose an arbitrary executable.

IMPORTANT: The `script` plug-in is provided mainly for compatibility
with earlier releases. Prefer other *TuneD* plug-ins if they cover
the required functionality.

*TuneD* calls the executable with one of the following arguments:

* `start` when loading the profile
* `stop` when unloading the profile

You need to correctly implement the `stop` action in your executable
and revert all settings that you changed during the `start`
action. Otherwise, the roll-back step after changing your *TuneD*
profile will not work.

Bash scripts can import the [filename]`/usr/lib/tuned/functions`
Bash library and use the functions defined there. Use these
functions only for functionality that is not natively provided
by *TuneD*. If a function name starts with an underscore, such as
`_wifi_set_power_level`, consider the function private and do not
use it in your scripts, because it might change in the future.

Specify the path to the executable using the `script` parameter in
the plug-in configuration.

.Running a Bash script from a profile
====
To run a Bash script named `script.sh` that is located in the profile
directory, use:
----
[script]
script=${i:PROFILE_DIR}/script.sh
----
====
c                s
    R R/# )scriptN )selfs   &@/usr/lib/python3.14/site-packages/tuned/plugins/plugin_script.py_get_config_optionsZ ScriptPlugin._get_config_options1   s     d
     c                s    R Vn         RVn        VP                  R,          e   VP                  R,          Vn        R# . Vn        R# )TFr   N)Z_has_static_tuningZ_has_dynamic_tuningZoptions_scriptsr   instance   &&r   _instance_initZScriptPlugin._instance_init7   s@     $(!&(h+  ''188r	   c                s    R # )Nr   r   r   r   _instance_cleanupZScriptPlugin._instance_cleanupA   s    r	   c                s   R pV EF  p\         P                  pVP                  V P                  P	                  4       4       V P                  V4      '       g&   \        P                  RRV,          ,           4       Ky  \        P                  RV: R\        V4      : R24       \        P                  R\        \        VP                  4       4      4      ,          4        \        V.V,           \        \        R VR \         P                  P!                  V4      R7      pVP#                  4       w  rx\%        V4      '       d"   \        P                  RV: R	VR
R : R24       VP&                  '       d-   \        P                  RWFP&                  3,          4       RpEK  EK  	  V#   \(        \*        3 d,   p	\        P                  RT: RT	: 24       Rp R
p	?	EK  R
p	?	ii ; i)TzGPaths outside of the profile directories cannot be used in the script, zignoring script: '%s'.zcalling script 'z' with arguments 'Z'zusing environment '%s')ZstdoutZstderrZ	close_fdsZenvZuniversal_newlinesZcwdzscript 'z' error output: 'Nz#script '%s' returned error code: %dFz	' error: i)osenvironZupdateZ
_variablesZget_envZ_safe_script_pathlogerrorinfoZstrZdebugZlistZitemsr   r   ZpathZdirnameZcommunicateZlenZ
returncodeZOSErrorZIOError)
r   ZscriptsZ	argumentsretr   r   ZprocZoutZerrZes
   &&&       r   _call_scriptsZScriptPlugin._call_scriptsD   sa   #fZZ7
>>$//))+,

 
 
(
(IIW&() *88YPQ99%D,A(BBC&Y&$'GGOOF#	%D
 !HC
3xxYY63s8DEYY47PPQS % 0 
* 7
 II34
Cs   "BF*7)F**G&;G!!G&c                sh   < \         \        V `  V4       V P                  VP                  R .4       R# )ZstartN)superr   _instance_apply_staticr   r
   )r   r   	__class__s   &&r   r   Z#ScriptPlugin._instance_apply_static`   s*    d28<X&&	2r	   c                s  < R p\         \        V `  VW#4      R8X  d   RpR.pV'       d   VR.,          pV P                  VP                  V4      R 8X  d7   \
        P                  \        P                  VP                  ,          4       V# \
        P                  \        P                  VP                  ,          4       RpV# )TFZverifyignore_missing)r   r   _instance_verify_staticr   r
   r   r   constsZSTR_VERIFY_PROFILE_OKr   ZSTR_VERIFY_PROFILE_FAIL)r   r   r   Zdevicesr   argsr   s   &&&&  r   r   Z$ScriptPlugin._instance_verify_staticd   s    #
<6x %&	3
$4	))40D888F((8+<+<<= 
* 99V++h.?.??@	3	*r	   c                s   < R .pV\         P                  8X  d   VR.,           pV P                  \        VP                  4      V4       \
        \        V `  W4       R# )ZstopZfull_rollbackN)r   ZROLLBACK_FULLr   Zreversedr
   r   r   _instance_unapply_static)r   r   Zrollbackr   r   s   &&& r   r   Z%ScriptPlugin._instance_unapply_statics   sO    
$%%%
/"
"4Xh//0$7d4XHr	   r   )Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__Zclassmethodr   r   r   r   r   r   r   ZROLLBACK_SOFTr   Z__static_attributes__Z__classdictcell__Z__classcell__)r   Z__classdict__s   @@r   r   r   	   sP     %N  
83 :@9M9M I Ir	   r   )Ztuned.constsr   Z r    Z
tuned.logsZtunedr   Z
subprocessr   r   ZlogsZgetr   ZPluginr   r   r	   r   <module>r      s8       	 "jjnnoI4;; oIr	   