From 2165226bf04d177ad5ff2b42f148a4b9aa2f12b0 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Fri, 27 Feb 2026 23:45:46 +0100 Subject: Add the role to switch gpu For Mac Machines with iGPU and dedicated GPU, this installs the gpu-switch to allow setting the active GPU on the next boot --- roles/gpu-switch/defaults/main.yml | 2 ++ roles/gpu-switch/meta/argument_specs.yml | 10 ++++++++++ roles/gpu-switch/meta/main.yml | 12 ++++++++++++ roles/gpu-switch/tasks/main.yml | 22 ++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 roles/gpu-switch/defaults/main.yml create mode 100644 roles/gpu-switch/meta/argument_specs.yml create mode 100644 roles/gpu-switch/meta/main.yml create mode 100644 roles/gpu-switch/tasks/main.yml (limited to 'roles') diff --git a/roles/gpu-switch/defaults/main.yml b/roles/gpu-switch/defaults/main.yml new file mode 100644 index 00000000..db1abd44 --- /dev/null +++ b/roles/gpu-switch/defaults/main.yml @@ -0,0 +1,2 @@ +--- +gpu_switch_dedicated: false diff --git a/roles/gpu-switch/meta/argument_specs.yml b/roles/gpu-switch/meta/argument_specs.yml new file mode 100644 index 00000000..46632ea4 --- /dev/null +++ b/roles/gpu-switch/meta/argument_specs.yml @@ -0,0 +1,10 @@ +--- +argument_specs: + main: + short_description: "Install gpu-switch" + description: "Install gpu-switch" + options: + gpu_switch_dedicated: + type: "bool" + default: false + description: "Enable dedicated GPU on machine when true other wise use default iGPU" diff --git a/roles/gpu-switch/meta/main.yml b/roles/gpu-switch/meta/main.yml new file mode 100644 index 00000000..3a4515bb --- /dev/null +++ b/roles/gpu-switch/meta/main.yml @@ -0,0 +1,12 @@ +--- +dependencies: + - role: "yay" +galaxy_info: + author: "a14m" + description: "Install gpu-switch" + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "ArchLinux" + versions: + - "all" diff --git a/roles/gpu-switch/tasks/main.yml b/roles/gpu-switch/tasks/main.yml new file mode 100644 index 00000000..14cc3be2 --- /dev/null +++ b/roles/gpu-switch/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: "Ensure gpu-switch is installed" + become: true + become_user: "aur_builder" + kewlfft.aur.aur: + name: "gpu-switch" + state: "present" + use: "yay" + +- name: "Configure gpu-switch to use dedicated GPU" + become: true + ansible.builtin.command: + cmd: "gpu-switch -d" + changed_when: false + when: gpu_switch_dedicated + +- name: "Configure gpu-switch to use integrated GPU" + become: true + ansible.builtin.command: + cmd: "gpu-switch -i" + changed_when: false + when: not gpu_switch_dedicated -- cgit v1.2.3