__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
-- WirePlumber
--
-- Copyright © 2022 Collabora Ltd.
--
-- SPDX-License-Identifier: MIT
--
-- Find the best profile for a device based on profile priorities and
-- availability

cutils = require ("common-utils")
log = Log.open_topic ("s-device")

SimpleEventHook {
  name = "device/find-best-profile",
  after = "device/find-preferred-profile",
  before = "device/apply-profile",
  interests = {
    EventInterest {
      Constraint { "event.type", "=", "select-profile" },
    },
  },
  execute = function (event)
    local selected_profile = event:get_data ("selected-profile")

    -- skip hook if profile is already selected
    if selected_profile then
      return
    end

    local device = event:get_subject ()
    local dev_name = device.properties["device.name"] or ""
    local off_profile = nil
    local best_profile = nil
    local unk_profile = nil
    -- Takes absolute priority if available or unknown
    local profile_prop = device.properties["device.profile"]


    for p in device:iterate_params ("EnumProfile") do
      profile = cutils.parseParam (p, "EnumProfile")
      if profile and profile.name == profile_prop and profile.available ~= "no" then
        selected_profile = profile
        goto profile_set
      elseif profile and profile.name ~= "pro-audio" then
        if profile.name == "off" then
          off_profile = profile
        elseif profile.available == "yes" then
          if best_profile == nil or profile.priority > best_profile.priority then
            best_profile = profile
          end
        elseif profile.available ~= "no" then
          if unk_profile == nil or profile.priority > unk_profile.priority then
            unk_profile = profile
          end
        end
      end
    end

    if best_profile ~= nil then
      selected_profile = best_profile
    elseif unk_profile ~= nil then
      selected_profile = unk_profile
    elseif off_profile ~= nil then
      selected_profile = off_profile
    end

::profile_set::
    if selected_profile then
      log:info (device, string.format (
          "Found best profile '%s' (%d) for device '%s'",
          selected_profile.name, selected_profile.index, dev_name))
      event:set_data ("selected-profile", selected_profile)
    end
  end
}:register()

Filemanager

Name Type Size Permission Actions
apply-profile.lua File 1.75 KB 0644
apply-routes.lua File 3.42 KB 0644
autoswitch-bluetooth-profile.lua File 14.93 KB 0644
find-best-profile.lua File 2.21 KB 0644
find-best-routes.lua File 2.49 KB 0644
find-preferred-profile.lua File 2.09 KB 0644
select-profile.lua File 720 B 0644
select-routes.lua File 4.9 KB 0644
state-profile.lua File 4.11 KB 0644
state-routes.lua File 10.5 KB 0644
Filemanager