device-profile-hooks: move the selected profile check

move the check to the beginning of the hook.
This commit is contained in:
Ashok Sidipotu 2024-02-08 13:19:26 +05:30
parent ad8d7aaf75
commit 112a45a230
2 changed files with 8 additions and 6 deletions

View file

@ -21,6 +21,12 @@ SimpleEventHook {
},
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"]
local off_profile = nil
@ -29,10 +35,6 @@ SimpleEventHook {
-- Takes absolute priority if available or unknown
local profile_prop = device.properties["device.profile"]
-- skip hook if profile is already selected
if selected_profile then
return
end
for p in device:iterate_params ("EnumProfile") do
profile = cutils.parseParam (p, "EnumProfile")

View file

@ -28,14 +28,14 @@ find_stored_profile_hook = SimpleEventHook {
},
execute = function (event)
local selected_profile = event:get_data ("selected-profile")
local device = event:get_subject ()
local dev_name = device.properties["device.name"]
-- 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"]
if not dev_name then
log:critical (device, "invalid device.name")
return