From 7c30f1aa6354539737fa773254d2299a361cfe29 Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 16 Feb 2022 23:00:33 +0100 Subject: [PATCH] improve powerplan options --- files/disable-screensaver.ps1 | 4 ---- tasks/main.yml | 2 +- tasks/powerplan.yml | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) delete mode 100644 files/disable-screensaver.ps1 diff --git a/files/disable-screensaver.ps1 b/files/disable-screensaver.ps1 deleted file mode 100644 index 14426b4..0000000 --- a/files/disable-screensaver.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -Write-Host "Disabling Screensaver" -Set-ItemProperty "HKCU:\Control Panel\Desktop" -Name ScreenSaveActive -Value 0 -Type DWord -& powercfg -x -monitor-timeout-ac 0 -& powercfg -x -monitor-timeout-dc 0 diff --git a/tasks/main.yml b/tasks/main.yml index 3c58928..f1d054a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,6 +9,6 @@ ansible.builtin.include_tasks: autologon.yml when: win_obs_init__autologon | bool -- name: change the power plan to high performance +- name: "change the power plan to {{ win_obs_init_powerplan_mode }}" ansible.builtin.include_tasks: powerplan.yml when: win_obs_init__powerplan_enabled | bool diff --git a/tasks/powerplan.yml b/tasks/powerplan.yml index 2008235..4b2dcba 100644 --- a/tasks/powerplan.yml +++ b/tasks/powerplan.yml @@ -2,3 +2,22 @@ - name: change the power plan to high performance community.windows.win_power_plan: name: "{{ win_obs_init_powerplan_mode }}" + +- name: "apply custom powerplan poweshell script as {{ win_obs_init__user }}" + ansible.windows.win_powershell: + script: | + Write-Host "Disabling Screensaver" + Set-ItemProperty "HKCU:\Control Panel\Desktop" -Name ScreenSaveActive -Value 0 -Type DWord + & powercfg -x -monitor-timeout-ac 0 + & powercfg -x -monitor-timeout-dc 0 + & powercfg -x standby-timeout-ac 0 + & powercfg -x standby-timeout-dc 0 + & powercfg -x hibernate-timeout-ac 0 + & powercfg -x hibernate-timeout-dc 0 + & powercfg -x disk-timeout-ac 0 + & powercfg -x disk-timeout-dc 0 + become: true + become_method: runas + become_user: "{{ win_obs_init__user }}" + vars: + ansible_become_pass: '{{ win_obs_init__password }}'