diff --git a/group_vars/all.yml b/group_vars/all.yml new file mode 100644 index 0000000..a0d2313 --- /dev/null +++ b/group_vars/all.yml @@ -0,0 +1,3 @@ +isNotebook: true +isDesktop: false +isVm: false \ No newline at end of file diff --git a/roles/desktop-environment/tasks/main.yml b/roles/desktop-environment/tasks/main.yml index 7761a65..d5ebd41 100644 --- a/roles/desktop-environment/tasks/main.yml +++ b/roles/desktop-environment/tasks/main.yml @@ -20,21 +20,70 @@ - fonts-noto-color-emoji - name: Add flathub remote to flatpak - become: yes community.general.flatpak_remote: name: flathub state: present flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo method: user -- name: Install wezterm - become: yes +- name: Install flatpaks community.general.flatpak: - name: org.wezfurlong.wezterm + name: "{{ item }}" state: present method: user + loop: + - org.wezfurlong.wezterm -- name: Copy config files +- name: Create group for sudoers config + become: yes + group: + name: admins + state: present + +- name: Add user to group for sudoers config + become: yes + user: + append: true + name: "{{ ansible_user_id }}" + groups: + - admins + +- name: Create sudoers config + become: yes + community.general.sudoers: + name: desktop-environment + group: admins + nopassword: true + commands: + - "/usr/bin/systemctl poweroff" + - "/usr/bin/systemctl reboot" + - "/usr/bin/systemctl suspend" + +- name: Copy static config files copy: - src: "{{ role_path }}/files/" - dest: "{{ ansible_env.HOME }}" \ No newline at end of file + src: "{{ item.src }}" + dest: "{{ item.dest }}" + loop: + - src: "{{ role_path }}/files/.config" + dest: "{{ ansible_env.HOME }}/" + +- name: Ensure presence of required directories + file: + path: "{{ item }}" + recurse: yes + state: directory + loop: + - "{{ ansible_env.HOME }}/.config/sway" + - "{{ ansible_env.HOME }}/.config/waybar" + +- name: Render config files + ansible.builtin.template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + loop: + - src: "bash_profile.j2" + dest: "{{ ansible_env.HOME }}/.bash_profile" + - src: "sway-config.j2" + dest: "{{ ansible_env.HOME }}/.config/sway/config" + - src: "waybar-config.j2" + dest: "{{ ansible_env.HOME }}/.config/waybar/config" \ No newline at end of file diff --git a/roles/desktop-environment/files/.bash_profile b/roles/desktop-environment/templates/bash_profile.j2 similarity index 86% rename from roles/desktop-environment/files/.bash_profile rename to roles/desktop-environment/templates/bash_profile.j2 index 7ab61fc..aa2e162 100644 --- a/roles/desktop-environment/files/.bash_profile +++ b/roles/desktop-environment/templates/bash_profile.j2 @@ -14,4 +14,7 @@ fi export GPG_TTY=$(tty) # Autostart sway at login +{% if isVm == true %} +export WLR_NO_HARDWARE_CURSORS=1 +{% endif %} if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec sway; fi \ No newline at end of file diff --git a/roles/desktop-environment/files/.config/sway/config b/roles/desktop-environment/templates/sway-config.j2 similarity index 98% rename from roles/desktop-environment/files/.config/sway/config rename to roles/desktop-environment/templates/sway-config.j2 index 1fc864a..48ab43d 100644 --- a/roles/desktop-environment/files/.config/sway/config +++ b/roles/desktop-environment/templates/sway-config.j2 @@ -213,7 +213,6 @@ exec hash dbus-update-activation-environment 2>/dev/null && \ exec waybar # Autostart applications -#exec waybar exec --no-startup-id nextcloud --background # Theme colors @@ -225,20 +224,20 @@ client.placeholder #c6c6c6 #1f1f1f #c6c6c6 #8abeb7 #8abeb7 client.background #1f1f1f +{% if isNotebook == true %} # backlight control - bindsym XF86MonBrightnessUp exec --no-startup-id brightnessctl -d intel_backlight set +5% bindsym XF86MonBrightnessDown exec --no-startup-id brightnessctl -d intel_backlight set 5%- -# set power-manager and volume control - +# set volume control bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -c 0 -q set Master 2dB+ unmute bindsym XF86AudioLowerVolume exec --no-startup-id amixer -c 0 -q set Master 2db- unmute bindsym XF86AudioMute exec --no-startup-id amixer -q set Master toggle -# touchpad on and off controller on laptop with Fn+ +# touchpad on and off controller on laptops with Fn keys bindsym XF86TouchpadOn exec --no-startup-id synclient Touchpadoff=0 bindsym XF86TouchpadOff exec --no-startup-id synclient Touchpadoff=1 +{% endif %} focus_follows_mouse no diff --git a/roles/desktop-environment/files/.config/waybar/config b/roles/desktop-environment/templates/waybar-config.j2 similarity index 96% rename from roles/desktop-environment/files/.config/waybar/config rename to roles/desktop-environment/templates/waybar-config.j2 index 77a03f2..076ba43 100644 --- a/roles/desktop-environment/files/.config/waybar/config +++ b/roles/desktop-environment/templates/waybar-config.j2 @@ -30,11 +30,13 @@ "reverse-scrolling": true, "on-click": "swaymsg exec amixer -q set Master toggle" }, + {% if isNotebook == true %} "battery": { "format": "{icon} {capacity}%", "format-charging": " {capacity}%", "format-icons": ["", "", "", "", ""] }, + {% endif %} "custom/power":{ "format":"  ", "on-click":"swaynag -t warning -m 'Power Menu Options' -b 'Logout' 'swaymsg exit' -b 'Suspend' 'swaymsg exec sudo systemctl suspend' -b 'Reboot' 'swaymsg exec sudo systemctl reboot' -b 'Shutdown' 'swaymsg exec sudo systemctl poweroff'"