Chad 392294fb45
General Enhancements, NixOS Support (#47)
* Begin adding Nix.

* Install LBRY from Nix since its Flatpak is no longer supported..

* Got the global install to work, now just figuring out why LBRY won't work.

* Add alias to blow away dev branch and start back up from remote or main.

* Nix install not really working, requires manual intervention, maybe add to setup.sh or just try NixOS and see if it can 'replace' this entire Ansible project and cease the use of multiple operating systems.

* Start working on having a path for NixOS.

* Add NixOS.

* Skip the installer portion if using NixOS.

* Start including more tasks. ALl work besides GNOME due to psutil, even though it is included in configuration.nix.

* This should have never been added. Was an accident if it snuck though.

* Test using env rather than hard-coded bash path.

* Use variables, start thinking about future.

* Add file to manage setting up NixOS for the first or any subsequent times.

* Use the new nixos.sh script.

* Ensure /usr/local/bin is in PATH.

* Do not use * inside of "" for ls.

* Add filename cleanup shortcut.

* Add a clean option as well as a few bugfixes and checking that convert is installed.

* Use underscores in filenames and remove plurality.

* Bring the file into better column compliance.

* Stop running the dconf psutil failures against NixOS for now.

* Ensure the old names of scripts are removed from bin.

* Clean filename fixes as well as a traversing version.

* Remove extra spacing.

* Begin adding swapfile creation.

* Add dangerous code reset command.

* Add some cleaning for NixOS package manager.

* The ~ was being taken literally and created as a new folder.

* More work on swap files, and a new ansible.nix file.

* Fix the swap confuration line.

* Finish the swap configuration by checking if it already exists. Always keep the fstab line in existence.

* Reorder and enhance the update function for NixOS.

* Add comment.

* Start working on dconf for NixOS since don't have home-manager working yet in configration.nix.

* Add notes.

* If the file was created, make sure the user owns it and can edit by default.

* Favorites are working and only need maintained in one place! :)

* Add .zshrc for GNOME settings on NixOS.

* Add most other settings that are done manually post-install. Report any failures with their placement.

* FINALLY! Keyboard shortcuts and some final Gnome Tweak settings!

* Add night light settings.

* Move around some comments.

* Pull first then deal with any merge issues, rather than trying to push when there are things to pull.

* Test removing the dconf commands for non-NixOS.

* Alter output; remove extra newlines and add cache verbosity.

* dconf in rc files is working on Ubuntu!

* Add delete. Fix filename quotes. Other enhancements.

* Create new folder chain if clean changed directory names.

* Add TBD about changing the directory structure.

* Only say success if the file really exists. Skip if conversion fails.

* Only say success if the file really exists. Skip if conversion fails.

* Add quotes around dirname.

* Add quotes around the entire directory tree.

* Add quotes to comment in case it ever gets used.

* Add a bittorrent client.

* Disable Bluetooth on all devices, it's normally off anyways.

* Fix comments, this enables not disables.

* Create new services report.

* Add services report to main area and move all reports to NixOS area.

* Fix swap file variable name for non-NixOS distros.

* Add godot editor.

* Re-add extra programs Geary and OpenShot for variety.

* Shorten the output for 80 char terminals.

* Add Code-OSS for when Codium is having issues.

* Allow code-oss to be installed.

* Add the full desktop entry for Code-OSS.

* Ansible handles the newlines, prevent the -e from getting into the file.

* Enhance newlines in nmap report.

* Add NixOS.
2023-10-17 04:30:36 -07:00

410 lines
17 KiB
YAML

---
# GNOME settings, extensions, and setup.
- name: Workstation | Account Management | GNOME | Facts
set_fact:
# Only do multiple entries per line if they are for the same exact program.
gnome_favorites: "[ 'org.gnome.Terminal.desktop'
, 'org.gnome.Console.desktop'
, 'gnome-system-monitor.desktop'
, 'org.gnome.Nautilus.desktop'
, 'io.gitlab.librewolf-community.desktop', 'librewolf.desktop'
, 'org.mozilla.firefox.desktop', 'firefox.desktop'
, 'org.gnome.Evolution.desktop'
, 'chat.delta.desktop.desktop', 'deltachat.desktop'
, 'org.gnome.Geary.desktop'
, 'org.mozilla.Thunderbird.desktop'
, 'com.vscodium.codium.desktop', 'codium.desktop'
, 'com.visualstudio.code-oss.desktop', 'code-oss.desktop'
, 'org.godotengine.Godot.desktop'
, 'org.shotcut.Shotcut.desktop'
, 'io.lbry.lbry-app.desktop', 'lbry.desktop'
, 'org.signal.Signal.desktop', 'signal-desktop.desktop'
, 'im.riot.Riot.desktop'
, 'org.telegram.desktop.desktop'
, 'com.discordapp.Discord.desktop'
, 'com.valvesoftware.Steam.desktop'
]"
dconf_terminal: gnome-terminal
dconf_theme: Adwaita-dark
dconf_icons: Adwaita
- name: Workstation | Account Management | GNOME | Facts (NixOS)
set_fact:
dconf_terminal: kgx
when: ansible_distribution in ("NixOS")
- name: Workstation | Account Management | GNOME | Facts (Ubuntu)
set_fact:
dconf_theme: Yaru-purple-dark
dconf_icons: Yaru-purple-dark
when: ansible_distribution in ("Ubuntu")
# Make sure Gnome-Tweaks is installed
- name: Workstation | Account Management | GNOME | Install Dependencies
package:
name:
- "{{ gnome_tweaks }}"
- "{{ dconf_editor }}"
- "{{ psutil }}"
state: present
when: ansible_distribution not in ("NixOS")
## Dash to Dock Extension ##
# Note: Validate DtD by checking /org/gnome/shell/enabled-extensions for dash-to-dock@micxgx.gmail.com
- name: Workstation | Account Management | GNOME | Dash To Dock
block:
- name: Workstation | Account Management | GNOME | Dash To Dock | Check
shell: "cd ~/.local/share/gnome-shell/extensions/dash-to-dock@micxgx.gmail.com/"
become_user: "{{ user }}"
register: dash_to_dock_exists
# Install #
# https://micheleg.github.io/dash-to-dock/download.html
- name: Workstation | Account Management | GNOME | Dash To Dock | Install | Clone Repo
git:
repo: https://github.com/micheleg/dash-to-dock.git
dest: "~/TRASH/dash-to-dock/"
clone: yes
force: no
version: master
become_user: "{{ user }}"
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | Install | Dependencies
package:
name:
- "{{ make }}"
- "{{ msgfmt }}"
- "{{ sassc }}"
state: present
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | Install | Make
shell: "cd ~/TRASH/dash-to-dock/; {{ make }}; {{ make }} install"
become_user: "{{ user }}"
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | Read Enabled Extension Array
dconf:
key: /org/gnome/shell/enabled-extensions
state: read
become_user: "{{ user }}"
register: gnome_enabled_extensions
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | dconf Return Object
debug:
var: gnome_enabled_extensions
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
# https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_filters.html#filters-for-formatting-data
- name: Workstation | Account Management | GNOME | Dash To Dock | Variables 1
set_fact:
gnome_enabled_extensions: "{{ gnome_enabled_extensions.value | replace('@as ', '') }}"
dash_to_dock_ext_comma: ""
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | After replace()
debug:
var: gnome_enabled_extensions
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | Variables 2
set_fact:
dash_to_dock_ext_comma: ", "
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed and gnome_enabled_extensions not in ("[]", [], "None")
- name: Workstation | Account Management | GNOME | Dash To Dock | Variables 3
set_fact:
dash_to_dock_ext_name: "{{ dash_to_dock_ext_comma }}'dash-to-dock@micxgx.gmail.com']"
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | Variables 4
set_fact:
gnome_enabled_extensions: "[]"
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed and gnome_enabled_extensions == "None"
- name: Workstation | Account Management | GNOME | Dash To Dock | Print Value To Append With
debug:
var: dash_to_dock_ext_name
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | Print Value To Append To
debug:
var: gnome_enabled_extensions
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | Print Combined Value
debug:
msg: "{{ gnome_enabled_extensions | replace(']', dash_to_dock_ext_name) }}"
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
- name: Workstation | Account Management | GNOME | Dash To Dock | Enable
dconf:
key: /org/gnome/shell/enabled-extensions
value: "{{ gnome_enabled_extensions | replace(']', dash_to_dock_ext_name) }}"
state: present
become_user: "{{ user }}"
when: ansible_distribution not in ("Ubuntu") and dash_to_dock_exists.failed
# Settings #
- name: Workstation | Account Management | GNOME | Dash To Dock | Dock Position
dconf:
key: /org/gnome/shell/extensions/dash-to-dock/dock-position
value: "'LEFT'"
state: present
become_user: "{{ user }}"
- name: Workstation | Account Management | GNOME | Dash To Dock | Dock Fixed
dconf:
key: /org/gnome/shell/extensions/dash-to-dock/dock-fixed
value: "true"
state: present
become_user: "{{ user }}"
- name: Workstation | Account Management | GNOME | Dash To Dock | Icon Size
dconf:
key: /org/gnome/shell/extensions/dash-to-dock/dash-max-icon-size
value: "28"
state: present
become_user: "{{ user }}"
when: ansible_distribution not in ("NixOS")
ignore_errors: yes
# End block for Dash To Dock.
## TBD Remove this after testing the RC version is successful on Ubuntu.
#- name: Workstation | Account Management | GNOME | More Settings
# block:
#
# - name: Workstation | Account Management | GNOME + Cinnamon | Favorites (Linux)
# dconf:
# key: "{{ item }}"
# value: "{{ gnome_favorites }}"
# state: present
# become_user: "{{ user }}"
# #when: ansible_system == "Linux"
# loop:
# - /org/gnome/shell/favorite-apps
# # - /org/cinnamon/favorite-apps
# # As of 2023-07-01 this only sets the Menu Favorites on Cinnamon, not the
# # Panel Pins. Cannot find any details online of where the pinned application
# # data lives. Cloned and searched the linuxmint/cinnamon project too and
# # couldn't find which function handles it. Leaving the loop for it but it's
# # not what was hoped for and is sort of a TBD/TODO.
#
# ## This is now handled by the task above, it's OK to have values not found.
# #- name: Workstation | Account Management | GNOME | Favorites (FreeBSD)
# # dconf:
# # key: /org/gnome/shell/favorite-apps
# # value: "['org.gnome.Terminal.desktop', 'org.gnome.Nautilus.desktop',
# # 'firefox.desktop', 'org.gnome.Evolution.desktop', 'org.mozilla.Thunderbird.desktop',
# # 'code-oss.desktop', 'org.telegram.desktop.desktop']"
# # state: present
# # become_user: "{{ user }}"
# # when: ansible_system == "FreeBSD"
#
#
# ## Top Bar Settings ##
# # (Battery Percentage, Clock Weekday+Seconds, Calendar Week Numbers)
#
# - name: Workstation | Account Management | GNOME | Interface - Show Date
# dconf:
# key: /org/gnome/desktop/interface/clock-show-date
# value: "true"
# state: present
# become_user: "{{ user }}"
#
# - name: Workstation | Account Management | GNOME | Interface - 24h Format
# dconf:
# key: /org/gnome/desktop/interface/clock-format
# value: "'24h'"
# state: present
# become_user: "{{ user }}"
#
# - name: Workstation | Account Management | GNOME | Interface - Show Seconds
# dconf:
# key: /org/gnome/desktop/interface/clock-show-seconds
# value: "true"
# state: present
# become_user: "{{ user }}"
#
# - name: Workstation | Account Management | GNOME | Interface - Show Weekday
# dconf:
# key: /org/gnome/desktop/interface/clock-show-weekday
# value: "true"
# state: present
# become_user: "{{ user }}"
#
# - name: Workstation | Account Management | GNOME | Interface - 24h Format
# dconf:
# key: /org/gnome/desktop/interface/show-battery-percentage
# value: "true"
# state: present
# become_user: "{{ user }}"
#
# - name: Workstation | Account Management | GNOME | Interface - Show Week Date
# dconf:
# key: /org/gnome/desktop/calendar/show-weekdate
# value: "true"
# state: present
# become_user: "{{ user }}"
#
# ## TBD These are done for NixOS in the section below. ##
# # Never Prompt for Removal Media
#
# # Dark theme?
# #Pop-dark on Pop
# #Adwaita-dark on everything else
#
# # Window Titlebars (Titlebar Buttons Minimize)
# - name: Workstation | Account Management | GNOME | Window Buttons
# dconf:
# key: /org/gnome/desktop/wm/preferences/button-layout
# value: "'appmenu:minimize,close'"
# state: present
# become_user: "{{ user }}"
#
#
# # Security
# - name: Workstation | Account Management | GNOME | Privacy - Camera
# dconf:
# key: /org/gnome/desktop/privacy/disable-camera
# value: "true"
# state: present
# become_user: "{{ user }}"
#
# - name: Workstation | Account Management | GNOME | Privacy - Microphone
# dconf:
# key: /org/gnome/desktop/privacy/disable-microphone
# value: "true"
# state: present
# become_user: "{{ user }}"
#
# when: ansible_distribution not in ("NixOS")
## NixOS support, in an odd but working fashion for now. :)
- name: Workstation | Account Management | GNOME | Dash To Dock | NixOS
blockinfile:
path: "{{ user_user.home }}/{{ item }}"
block: |
## Temporary Variables + Functions ##
dconf_count=1
function inc_dconf() {
dconf_count=$(( dconf_count + 1 ))
}
## Dash to Dock ##
dconf write /org/gnome/shell/extensions/dash-to-dock/dock-position "'LEFT'" && inc_dconf &&
dconf write /org/gnome/shell/extensions/dash-to-dock/dock-fixed true && inc_dconf &&
dconf write /org/gnome/shell/extensions/dash-to-dock/dash-max-icon-size 24 && inc_dconf &&
dconf write /org/gnome/shell/favorite-apps "{{ gnome_favorites }}" && inc_dconf &&
## Generic ##
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'" && inc_dconf &&
dconf write /org/gnome/desktop/interface/gtk-theme "'{{ dconf_theme }}'" && inc_dconf &&
dconf write /org/gnome/desktop/interface/icon-theme "'{{ dconf_icons }}'" && inc_dconf &&
dconf write /org/gnome/desktop/interface/clock-show-date true && inc_dconf &&
dconf write /org/gnome/desktop/interface/clock-format "'24h'" && inc_dconf &&
dconf write /org/gnome/desktop/interface/clock-show-seconds true && inc_dconf &&
dconf write /org/gnome/desktop/interface/clock-show-weekday true && inc_dconf &&
dconf write /org/gnome/desktop/calendar/show-weekdate true && inc_dconf &&
dconf write /org/gnome/desktop/interface/show-battery-percentage true && inc_dconf &&
dconf write /org/gnome/desktop/wm/preferences/button-layout "'appmenu:minimize,maximize,close'" && inc_dconf &&
dconf write /org/gnome/desktop/wm/preferences/num-workspaces 1 && inc_dconf &&
dconf write /org/gnome/mutter/dynamic-workspaces false && inc_dconf &&
dconf write /org/gnome/mutter/edge-tiling true && inc_dconf &&
dconf write /org/gnome/desktop/interface/enable-hot-corners false && inc_dconf &&
dconf write /org/gnome/mutter/center-new-windows true && inc_dconf &&
dconf write /org/gnome/desktop/notifications/show-banners false && inc_dconf &&
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution-alarm-notify/enable-sound-alerts false && inc_dconf &&
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution-alarm-notify/enable false && inc_dconf &&
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution/enable-sound-alerts false && inc_dconf &&
dconf write /org/gnome/desktop/notifications/application/org-gnome-evolution/enable false && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/color/night-light-enabled true
dconf write /org/gnome/settings-daemon/plugins/color/night-light-schedule-automatic false
dconf write /org/gnome/settings-daemon/plugins/color/night-light-temperature "uint32 3170"
dconf write /org/gnome/settings-daemon/plugins/color/night-light-schedule-from 2.0
dconf write /org/gnome/settings-daemon/plugins/color/night-light-schedule-to 1.99
## Keyboard Shortcuts ##
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/binding \
"'<Control><Alt>t'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/command \
"'{{ dconf_terminal }}'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/name \
"'Open Terminal'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/binding \
"'<Super>t'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/command \
"'{{ dconf_terminal }}'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/name \
"'Open Terminal 2'" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings "
[ '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/'
, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/'
]" && inc_dconf &&
## Privacy ##
dconf write /org/gnome/desktop/privacy/disable-camera true && inc_dconf &&
dconf write /org/gnome/desktop/privacy/disable-microphone true && inc_dconf &&
dconf write /org/gnome/desktop/privacy/recent-files-max-age 7 && inc_dconf &&
dconf write /org/gnome/desktop/privacy/remember-recent-files false && inc_dconf &&
dconf write /org/gnome/desktop/privacy/old-files-age "uint32 14" && inc_dconf &&
dconf write /org/gnome/desktop/privacy/remove-old-trash-files true && inc_dconf &&
dconf write /org/gnome/desktop/privacy/remove-old-temp-files true && inc_dconf &&
dconf write /org/gnome/desktop/notifications/show-in-lock-screen false && inc_dconf &&
dconf write /org/gnome/desktop/screensaver/lock-enabled true && inc_dconf &&
dconf write /org/gnome/desktop/screensaver/lock-delay "uint32 0" && inc_dconf &&
dconf write /org/gnome/desktop/session/idle-delay "uint32 900" && inc_dconf &&
dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type "'nothing'" && inc_dconf &&
dconf write /org/gnome/desktop/media-handling/autorun-never true && inc_dconf &&
## Success ##
sleep 0 ||
## Error Catch ##
echo "ERROR: DConf setting# $dconf_count failed!"
## Cleanup ##
unset -f inc_dconf
unset dconf_count
marker: '# {mark} MANAGED BY ANSIBLE | NixOS GNOME Settings'
state: present
create: yes
backup: yes
become_user: "{{ user }}"
loop:
- .bashrc
- .zshrc
#when: ansible_distribution in ("NixOS")