---
- name: 40k Rice
  hosts: localhost
  connection: local

  tasks:
    - name: Set greenscreen pywal theme
      ansible.builtin.shell: wal --theme base16-greenscreen
      args: 
        executable: /bin/zsh

    - name: Set mechanicus wallpaper 
      ansible.builtin.shell: feh --bg-fill /home/vashqlf/Pictures/wallpapers/40k-mechanicus-2-green.png
      args: 
        executable: /bin/zsh

    - name: Copy 40k i3 config
      ansible.builtin.copy:
        src: /home/vashqlf/Code/Ansible/playbooks/rices/files/40k-i3
        dest: /home/vashqlf/.config/i3/config
        owner: vashqlf
        group: vashqlf
        mode: '0644'

    - name: Copy 40k i3 blocks config
      ansible.builtin.copy:
        src: /home/vashqlf/Code/Ansible/playbooks/rices/files/40k-blocks
        dest: /home/vashqlf/.config/i3/i3blocks.conf
        owner: vashqlf
        group: vashqlf
        mode: '0644'

    - name: Set gruvbox theme in nvim
      ansible.builtin.lineinfile:
        path: /home/vashqlf/.config/nvim/lua/chadrc.lua
        regexp: 'theme'
        line: '  theme = "greenscreen",' 

    - name: Reload NvChad config in running nvim instances
      ansible.builtin.shell: |
        for addr in $XDG_RUNTIME_DIR/nvim.*; do
          nvim --server $addr --remote-send ':lua require("nvchad.utils").reload() <cr>'
        done
      ignore_errors: true

    - name: Reload NvChad config in case not running 
      ansible.builtin.shell: nvim --headless "+lua require('nvchad.utils').reload()" +qa
      args: 
        executable: /bin/zsh

    - name: Fix rofi config 
      ansible.builtin.shell: /home/vashqlf/Code/Shell/rasi-wal-fix.sh
      args: 
        executable: /bin/zsh
  
    - name: Change fastfetch config to 40k
      ansible.builtin.lineinfile:
        path: /home/vashqlf/.zshrc
        regexp: '^fastfetch'
        line: fastfetch -c /home/vashqlf/.config/myfetch/40k-fetch.jsonc

    - name: Reload i3 config
      ansible.builtin.shell: i3-msg reload
      args: 
        executable: /bin/zsh
