8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

在 gnome 扩展中截屏时删除弹出窗口和声音

ryandra 2月前

73 0

当在 gnome 扩展中通过 captureScreenshot 函数进行截图时,会弹出一个窗口,并播放典型的拍照声音。extension.js:import {Extension} from 'reso...

在gnome扩展中截取屏幕截图时 captureScreenshot ,会弹出一个窗口,并播放典型的拍照声音。

扩展.js:

import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
import * as Screenshot from 'resource:///org/gnome/shell/ui/screenshot.js';
import Shell from 'gi://Shell';

export default class ExampleExtension extends Extension {
async enable() {
    const shooter = new Shell.Screenshot();
    const [content] = await shooter.screenshot_stage_to_content();
    const texture = content.get_texture();
    await Screenshot.captureScreenshot(texture, null, 1, null);
}

disable() {
}
}

弹出窗口:

enter image description here

如何安静地截取屏幕截图,不弹出窗口,不发出声音?例如,当外部应用程序通过 dbus API https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/blob/main/data/org.gnome.Shell.Screenshot.xml#L46 。在这种情况下,屏幕截图只是悄悄地添加到磁盘中,仅此而已。

Ubuntu 24.04,GNOME 46,Wayland

帖子版权声明 1、本帖标题:在 gnome 扩展中截屏时删除弹出窗口和声音
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由ryandra在本站《ubuntu》版块原创发布, 转载请注明出处!
最新回复 (0)
  • 为了在我的 Unity 游戏中创建爆炸,我将 3 个运行时配置的粒子系统集中起来,并将停止操作设置为禁用(这样我就可以将所有禁用的粒子对象集中起来);我做了类似的事情:p...

    为了在我的 Unity 游戏中创建爆炸,我将 3 个运行时配置的粒子系统池化,并将停止操作设置为禁用(这样我就可以将所有禁用的粒子对象池化);

    我做了这样的事情:

    public void CreateExplosions()
    {
        Pool_Particle_Simple(position, rotation, 8);
        Pool_Particle_Simple(position, rotation, 9);
        Pool_Particle_Simple(position, rotation, 10);
    }
    public PoolableParticle GetAvailabe_PoolParticle(PoolableParticle[] particles, int start, int end)
        {
            for (int i = start; i < end; i++)
            {
                PoolableParticle particle = particles[i];
                switch (particle.gameObject.activeInHierarchy)
                {
                    case false:
                        particles[i].gameObject.SetActive(true);
                        return particles[i];
    
                }
            }
            return null;
        }
    
        public void Pool_Particle_Simple(Vector3 position, Quaternion rotation, ushort type)
        {
            PoolableParticle particle = GetAvailabe_PoolParticle(poolableParticles, 0, poolableParticles.Length);
            switch (ReferenceEquals(particle, null))
            {
                case false:
                  
                    ParticleSystem particleSystem = particle.ParticleSystem;
                    SetupParticle(particleSystem, particle.ParticleSystemRenderer, type);
    
                    particleSystem.transform.position = position;
                    particle.transform.rotation = rotation;                
                    particleSystem.Play();
                    break;
            }
        }
    
        public void SetupParticle(ParticleSystem particleSystem, ParticleSystemRenderer renderer, int type)//0 = Smoke01, 1 = Smoke02, ...
        {
            switch (type)
            {
                case 0://Smoke01
    
                    ParticleSystem.MainModule main = particleSystem.main;
                    main.duration = 5;
                    main.loop = false;
                    main.prewarm = true;
                    main.startDelay = 0;
                    main.startLifetime = new ParticleSystem.MinMaxCurve(4, 6);
                    main.startSpeed = new ParticleSystem.MinMaxCurve(.5f, 1f);
                    main.startSize3D = false;
                    main.startSize = 55;
                    main.startRotation = 0;
                    main.flipRotation = 1;
                    main.startColor = Color.white;
                    main.gravityModifier = 0;
                    main.simulationSpace = ParticleSystemSimulationSpace.World;
                    main.simulationSpeed = 1;
                    main.scalingMode = ParticleSystemScalingMode.Local;
                    main.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Rigidbody;
                    main.maxParticles = 15;
                    main.cullingMode = ParticleSystemCullingMode.AlwaysSimulate;
                    main.ringBufferMode = ParticleSystemRingBufferMode.Disabled;
    
                    ParticleSystem.EmissionModule emission = particleSystem.emission;
                    emission.rateOverTime = 3;
                    emission.rateOverDistance = 0;
                    emission.burstCount = 0;
    
                    ParticleSystem.VelocityOverLifetimeModule velocity = particleSystem.velocityOverLifetime;
                    velocity.enabled = false;
    
                    ParticleSystem.LimitVelocityOverLifetimeModule limitVelocity = particleSystem.limitVelocityOverLifetime;
                    limitVelocity.enabled = false;
    
                    ParticleSystem.ShapeModule shape = particleSystem.shape;
                    shape.enabled = true;
                    shape.shapeType = ParticleSystemShapeType.Cone;
                    shape.angle = 25;
                    shape.radius = 0.3822865f;
                    shape.radiusThickness = 1;
                    shape.arc = 360;
                    shape.arcMode = ParticleSystemShapeMultiModeValue.Random;
                    shape.arcSpread = 0;
                    shape.length = 5;
                    shape.position = Vector3.zero;
                    shape.rotation = Vector3.zero;
                    shape.scale = Vector3.one;
                    shape.alignToDirection = false;
                    shape.randomDirectionAmount = 1;
                    shape.sphericalDirectionAmount = 0;
                    shape.randomPositionAmount = 0;
    
                    ParticleSystem.ForceOverLifetimeModule force = particleSystem.forceOverLifetime;
                    force.enabled = false;
    
                    ParticleSystem.ColorOverLifetimeModule color = particleSystem.colorOverLifetime;
                    color.enabled = true;
    
                    Gradient gradient = new Gradient();
                    gradient.mode = GradientMode.Blend;
                    GradientColorKey[] colorKeys = new GradientColorKey[2];
                    colorKeys[0] = new GradientColorKey(Color.white, 0f);
                    colorKeys[1] = new GradientColorKey(Color.white, 1f);
                    GradientAlphaKey[] alphaKeys = new GradientAlphaKey[4];
                    alphaKeys[0] = new GradientAlphaKey(0.12f, 0);
                    alphaKeys[1] = new GradientAlphaKey(.45f, 0.27f);
                    alphaKeys[2] = new GradientAlphaKey(.70f, .805f);
                    alphaKeys[3] = new GradientAlphaKey(0f, 1f);
                    gradient.SetKeys(colorKeys, alphaKeys);
                    color.color = gradient;
    
                    ParticleSystem.SizeOverLifetimeModule size = particleSystem.sizeOverLifetime;
                    size.separateAxes = false;
                    size.size = new ParticleSystem.MinMaxCurve(0, 1);
    
                    ParticleSystem.RotationOverLifetimeModule rotation = particleSystem.rotationOverLifetime;
                    rotation.enabled = true;
                    rotation.separateAxes = false;
          
                    rotation.z = .45f;
    
                    ParticleSystem.SubEmittersModule subEmitters = particleSystem.subEmitters;
                    subEmitters.enabled = false;
    
                    ParticleSystem.NoiseModule noise = particleSystem.noise;
                    noise.enabled = false;
    
                    ParticleSystem.TrailModule trails = particleSystem.trails;
                    trails.enabled = false;
    
                    renderer.renderMode = ParticleSystemRenderMode.Mesh;
                    renderer.meshDistribution = ParticleSystemMeshDistribution.UniformRandom;
                    renderer.sortMode = ParticleSystemSortMode.None;
                    renderer.sortingFudge = 0;
                    renderer.alignment = ParticleSystemRenderSpace.Local;
                    renderer.flip = Vector3.zero;
                    renderer.enableGPUInstancing = false;
                    renderer.pivot = Vector3.zero;
                    renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                    renderer.sortingLayerID = 0;
                    renderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.BlendProbes;
                    renderer.probeAnchor = null;
    
                    break;
    
                case 8://Small Explosion (base)
    
                    main = particleSystem.main;
                    main.duration = 2f;
                    main.loop = false;
                    main.prewarm = false;
                    main.startDelay = 0f;
                    main.startLifetime = new ParticleSystem.MinMaxCurve(.75f, 1f);
                    main.startSpeed = 0;
                    main.startSize3D = false;
                    main.startSize = new ParticleSystem.MinMaxCurve(1f, 2f);
                    main.startRotation = new ParticleSystem.MinMaxCurve(0, 360);
                    main.flipRotation = 0;
                    main.startColor = Color.white;
                    main.gravityModifier = 0;
                    main.simulationSpace = ParticleSystemSimulationSpace.Local;
                    main.simulationSpeed = 1;
                    main.scalingMode = ParticleSystemScalingMode.Local;
                    main.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
                    main.maxParticles = 1000;
                    main.cullingMode = ParticleSystemCullingMode.AlwaysSimulate;
                    main.ringBufferMode = ParticleSystemRingBufferMode.Disabled;
    
                    emission = particleSystem.emission;
                    emission.rateOverTime = 0;
                    emission.rateOverDistance = 0;
                    ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[1];
                    bursts[0] = new ParticleSystem.Burst(0f, (short)5, (short)5, 1, 0.050f);
                    emission.SetBursts(bursts);
    
                    shape = particleSystem.shape;
                    shape.enabled = true;
                    shape.shapeType = ParticleSystemShapeType.Sphere;
                    shape.radius = 0.2442369f;
                    shape.radiusThickness = 1;
                    shape.arc = 360;
                    shape.arcMode = ParticleSystemShapeMultiModeValue.Random;
                    shape.arcSpread = 0;
                    shape.position = Vector3.zero;
                    shape.rotation = Vector3.zero;
                    shape.scale = Vector3.one;
                    shape.alignToDirection = false;
                    shape.randomDirectionAmount = 0;
                    shape.randomPositionAmount = 0;
                    shape.sphericalDirectionAmount = 0;
    
                    velocity = particleSystem.velocityOverLifetime;
                    velocity.space = ParticleSystemSimulationSpace.Local;
                    velocity.enabled = true;
                    velocity.xMultiplier = 0;
                    velocity.orbitalX = 0;
                    velocity.orbitalOffsetX = 0;
                    velocity.yMultiplier = 0;
                    velocity.orbitalY = 0;
                    velocity.orbitalOffsetY = 0;
                    velocity.zMultiplier = 0;
                    velocity.orbitalZ = 0;
                    velocity.orbitalOffsetZ = 0;
                    velocity.radial = new ParticleSystem.MinMaxCurve(0f, 2f);
                    velocity.speedModifier = 1;
    
                    force = particleSystem.forceOverLifetime;
                    force.enabled = false;
    
                    limitVelocity = particleSystem.limitVelocityOverLifetime;
                    limitVelocity.enabled = false;
    
                    color = particleSystem.colorOverLifetime;
                    color.enabled = true;
                    gradient = new Gradient();
                    gradient.mode = GradientMode.Blend;
                    colorKeys = new GradientColorKey[3];
                    colorKeys[0] = new GradientColorKey(Color.white, .019f);
                    colorKeys[1] = new GradientColorKey(Color.black, .036f);
                    colorKeys[2] = new GradientColorKey(Color.black, .694f);
                    alphaKeys = new GradientAlphaKey[3];
                    alphaKeys[0] = new GradientAlphaKey(1f, 0);
                    alphaKeys[1] = new GradientAlphaKey(1f, 0.688f);
                    alphaKeys[2] = new GradientAlphaKey(0f, 1f);
                    gradient.SetKeys(colorKeys, alphaKeys);
                    color.color = gradient;
    
                    size = particleSystem.sizeOverLifetime;
                    size.separateAxes = false;
                    size.size = new ParticleSystem.MinMaxCurve(1, 2);
    
                    rotation = particleSystem.rotationOverLifetime;
                    rotation.enabled = false;
    
                    subEmitters = particleSystem.subEmitters;
                    subEmitters.enabled = false;
    
                    noise = particleSystem.noise;
                    noise.enabled = false;
    
                    trails = particleSystem.trails;
                    trails.enabled = false;
    
                    renderer.renderMode = ParticleSystemRenderMode.Billboard;
                    renderer.normalDirection = 1;
                    renderer.sortMode = ParticleSystemSortMode.Distance;
                    renderer.sortingFudge = 0;
                    renderer.minParticleSize = 0;
                    renderer.maxParticleSize = 5f;
                    renderer.alignment = ParticleSystemRenderSpace.View;
                    renderer.flip = new Vector3(.5f, .5f, 0);
                    renderer.allowRoll = true;
                    renderer.pivot = Vector3.zero;
                    renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                    renderer.shadowBias = 0;
                    renderer.sortingLayerID = 0;
                    renderer.sortingOrder = 0;
                    renderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
    
                    break;
    
                case 9://Small Explosion (additional smoke)
    
                    main = particleSystem.main;
                    main.duration = 2f;
                    main.loop = false;
                    main.prewarm = false;
                    main.startDelay = 0f;
                    main.startLifetime = new ParticleSystem.MinMaxCurve(1.5f, 1.2f);
                    main.startSpeed = 0;
                    main.startSize3D = false;
                    main.startSize = new ParticleSystem.MinMaxCurve(1.5f, 1f);
                    main.startRotation = new ParticleSystem.MinMaxCurve(0, 360);
                    main.flipRotation = 0;
                    main.startColor = Color.white;
                    main.gravityModifier = 0;
                    main.simulationSpace = ParticleSystemSimulationSpace.Local;
                    main.simulationSpeed = 1;
                    main.scalingMode = ParticleSystemScalingMode.Local;
                    main.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
                    main.maxParticles = 1000;
                    main.cullingMode = ParticleSystemCullingMode.AlwaysSimulate;
                    main.ringBufferMode = ParticleSystemRingBufferMode.Disabled;
    
                    emission = particleSystem.emission;
                    emission.rateOverTime = 0;
                    emission.rateOverDistance = 0;
                    bursts = new ParticleSystem.Burst[1];
                    bursts[0] = new ParticleSystem.Burst(0f, (short)10, (short)10, 1, 0.100f);
                    emission.SetBursts(bursts);
    
                    shape = particleSystem.shape;
                    shape.enabled = true;
                    shape.shapeType = ParticleSystemShapeType.Sphere;
                    shape.radius = 0.3957672f;
                    shape.radiusThickness = 0;
                    shape.arc = 360;
                    shape.arcMode = ParticleSystemShapeMultiModeValue.Random;
                    shape.arcSpread = 0;
                    shape.position = Vector3.zero;
                    shape.rotation = Vector3.zero;
                    shape.scale = Vector3.one;
                    shape.alignToDirection = false;
                    shape.randomDirectionAmount = 0;
                    shape.randomPositionAmount = 0;
                    shape.sphericalDirectionAmount = 0;
    
                    velocity = particleSystem.velocityOverLifetime;
                    velocity.enabled = true;
                    velocity.xMultiplier = 0;
                    velocity.orbitalX = 0;
                    velocity.orbitalOffsetX = 0;
                    velocity.yMultiplier = 2;
                    velocity.orbitalY = 0;
                    velocity.orbitalOffsetY = 0;
                    velocity.zMultiplier = 0;
                    velocity.orbitalZ = 0;
                    velocity.orbitalOffsetZ = 0;
                    velocity.radial = new ParticleSystem.MinMaxCurve(0f, 1f);
                    velocity.speedModifier = 1;
    
                    force = particleSystem.forceOverLifetime;
                    force.enabled = false;
    
                    limitVelocity = particleSystem.limitVelocityOverLifetime;
                    limitVelocity.enabled = false;
    
                    color = particleSystem.colorOverLifetime;
                    color.enabled = true;
                    gradient = new Gradient();
                    gradient.mode = GradientMode.Blend;
                    colorKeys = new GradientColorKey[2];
                    colorKeys[0] = new GradientColorKey(new Color(255, 107, 1), 0f);
                    colorKeys[1] = new GradientColorKey(new Color(41, 41, 41), .341f);
    
                    alphaKeys = new GradientAlphaKey[4];
                    alphaKeys[0] = new GradientAlphaKey(0f, 0.01f);
                    alphaKeys[1] = new GradientAlphaKey(.5f, 0.247f);
                    alphaKeys[2] = new GradientAlphaKey(1f, .618f);
                    alphaKeys[3] = new GradientAlphaKey(0f, 1f);
                    gradient.SetKeys(colorKeys, alphaKeys);
                    color.color = gradient;
    
                    size = particleSystem.sizeOverLifetime;
                    size.separateAxes = false;
                    size.size = new ParticleSystem.MinMaxCurve(1, 2);
    
                    rotation = particleSystem.rotationOverLifetime;
                    rotation.enabled = false;
    
                    subEmitters = particleSystem.subEmitters;
                    subEmitters.enabled = false;
    
                    noise = particleSystem.noise;
                    noise.enabled = false;
    
                    trails = particleSystem.trails;
                    trails.enabled = false;
    
                    renderer.renderMode = ParticleSystemRenderMode.Billboard;
                    renderer.normalDirection = 1;
                    renderer.sortMode = ParticleSystemSortMode.Distance;
                    renderer.sortingFudge = 0;
                    renderer.minParticleSize = 0;
                    renderer.maxParticleSize = 5f;
                    renderer.alignment = ParticleSystemRenderSpace.View;
                    renderer.flip = new Vector3(.5f, .5f, 0);
                    renderer.allowRoll = true;
                    renderer.pivot = Vector3.zero;
                    renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                    renderer.shadowBias = 0;
                    renderer.sortingLayerID = 0;
                    renderer.sortingOrder = 1;
                    renderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
    
                    break;
    
                case 10://Small Explosion (shockWave)
    
                    main = particleSystem.main;
                    main.duration = 2f;
                    main.loop = false;
                    main.prewarm = false;
                    main.startDelay = 0f;
                    main.startLifetime = .5f;
                    main.startSpeed = 0;
                    main.startSize3D = false;
                    main.startSize = 10;
                    main.startRotation = 0;
                    main.flipRotation = 0;
                    main.startColor = Color.white;
                    main.gravityModifier = 0;
                    main.simulationSpace = ParticleSystemSimulationSpace.Local;
                    main.simulationSpeed = 1;
                    main.scalingMode = ParticleSystemScalingMode.Local;
                    main.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
                    main.maxParticles = 1000;
                    main.cullingMode = ParticleSystemCullingMode.AlwaysSimulate;
                    main.ringBufferMode = ParticleSystemRingBufferMode.Disabled;
    
                    emission = particleSystem.emission;
                    emission.rateOverTime = 0;
                    emission.rateOverDistance = 0;
                    bursts = new ParticleSystem.Burst[1];
                    bursts[0] = new ParticleSystem.Burst(0f, (short)1, (short)1, 1, 0.010f);
                    emission.SetBursts(bursts);
    
                    shape = particleSystem.shape;
                    shape.enabled = false;
    
                    velocity = particleSystem.velocityOverLifetime;
                    velocity.enabled = false;
    
                    force = particleSystem.forceOverLifetime;
                    force.enabled = false;
    
                    limitVelocity = particleSystem.limitVelocityOverLifetime;
                    limitVelocity.enabled = false;
    
                    color = particleSystem.colorOverLifetime;
                    color.enabled = true;
                    gradient = new Gradient();
                    gradient.mode = GradientMode.Blend;
                    colorKeys = new GradientColorKey[2];
                    colorKeys[0] = new GradientColorKey(Color.white, 0f);
                    colorKeys[1] = new GradientColorKey(Color.white, 1f);
                    alphaKeys = new GradientAlphaKey[2];
                    alphaKeys[0] = new GradientAlphaKey(1f, 0f);
                    alphaKeys[1] = new GradientAlphaKey(0f, 1f);
                    gradient.SetKeys(colorKeys, alphaKeys);
                    color.color = gradient;
    
                    size = particleSystem.sizeOverLifetime;
                    size.separateAxes = false;
                    size.size = new ParticleSystem.MinMaxCurve(0, 1);//Forse no
    
                    rotation = particleSystem.rotationOverLifetime;
                    rotation.enabled = false;
    
                    subEmitters = particleSystem.subEmitters;
                    subEmitters.enabled = false;
    
                    noise = particleSystem.noise;
                    noise.enabled = false;
    
                    trails = particleSystem.trails;
                    trails.enabled = false;
    
                    renderer.renderMode = ParticleSystemRenderMode.Billboard;
                    renderer.normalDirection = 1;
                    renderer.sortMode = ParticleSystemSortMode.None;
                    renderer.sortingFudge = 0;
                    renderer.minParticleSize = 0;
                    renderer.maxParticleSize = 20f;
                    renderer.alignment = ParticleSystemRenderSpace.View;
                    renderer.flip = Vector3.zero;
                    renderer.allowRoll = true;
                    renderer.pivot = Vector3.zero;
                    renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                    renderer.shadowBias = 0;
                    renderer.sortingLayerID = 0;
                    renderer.sortingOrder = 1;
                    renderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
    
                    break;
    
    
    //.....
    }
    

    问题是,有时我会得到像图片右侧那样的伪像,请 在此处输入图片说明 。相反,我希望得到像左侧那样的结果。通过查看检查器,两个校正粒子分子看起来相等,但正如您所见,结果非常不同(伪像非常大,颜色和形状错误)。什么可能导致该故障?

返回
作者最近主题: