diff --git a/.gitignore b/.gitignore index 51497828..42f6d573 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .gen +temp_bin diff --git a/home/.chezmoi.yaml.tmpl b/home/.chezmoi.yaml.tmpl new file mode 100644 index 00000000..474fe54f --- /dev/null +++ b/home/.chezmoi.yaml.tmpl @@ -0,0 +1,2 @@ +secret: + command: "rbw-get" diff --git a/home/.chezmoidata.yaml b/home/.chezmoidata.yaml new file mode 100644 index 00000000..d3fd81dd --- /dev/null +++ b/home/.chezmoidata.yaml @@ -0,0 +1,7 @@ +user: test +hostname: test +desktop: i3 # valid values: i3, gnome +network_interface: "eth0" +git_user: "starr-dusT" +git_email: &my_email "starrtyler88@gmail.com" +bitwarden_email: *my_email diff --git a/home/.chezmoiexternal.toml b/home/.chezmoiexternal.toml index afb20a5a..9cd40704 100644 --- a/home/.chezmoiexternal.toml +++ b/home/.chezmoiexternal.toml @@ -13,20 +13,14 @@ [".oh-my-zsh"] type = "archive" url = "https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz" + extact = true + stripComponents = 1 refreshPeriod = "168h" -[".oh-my-zsh/custom/themes"] +[".oh-my-zsh/custom/themes/dracula"] type = "archive" url = "https://github.com/dracula/zsh/archive/master.zip" exact = true stripComponents = 1 refreshPeriod = "168h" include = ["*/dracula.zsh-theme", "*/lib/**"] - -#[".oh-my-zsh/custom/themes/dracula.zsh-theme"] -# type = "file" -# url = "https://github.com/dracula/zsh/archive/master.zip" -# refreshPeriod = "168h" -# [".oh-my-zsh/custom/themes/dracula.zsh-theme".filter] -# command = "busybox" -# args = ["unzip", "/dev/stdin", "*/dracula.zsh-theme", "-p"] diff --git a/home/.chezmoiignore b/home/.chezmoiignore index 4b512897..015ca532 100644 --- a/home/.chezmoiignore +++ b/home/.chezmoiignore @@ -1,3 +1,4 @@ +.oh-my-zsh/cache/** readme.md .gitignore .git diff --git a/home/bin/executable_linux-monitor b/home/bin/executable_linux-monitor new file mode 100644 index 00000000..1604f8fd --- /dev/null +++ b/home/bin/executable_linux-monitor @@ -0,0 +1,107 @@ +#!/usr/bin/python +# +import subprocess +import json +import pathlib +import os +import re + +def select_options(message, options): + user_input = '' + input_message = message + '\n' + for index, item in enumerate(options): + input_message += f'{index+1}) {item}\n' + input_message += 'Your choice: ' + while user_input not in map(str, range(1, len(options) + 1)): + user_input = input(input_message) + return options[int(user_input) - 1] + +# save needed information in a dictionary +i3_dict = {} + +cmd = str(subprocess.check_output("xrandr", shell=True)) +outputs = [] +freqs = [] + +# Get avaiable outputs, resolutions, and freqs +need_res = False +for row in cmd.split('\\n'): + if " connected" in row: + need_res = True + outputs.append(row.split(" ")[0]) + continue + elif re.search('[0-9]x[0-9]', row): + freqs.append(row.split()) +resolutions = [item[0] for item in freqs] + +print('Setup monitor resolutions and freqs...') +monitor_set = {} +for index, output in enumerate(outputs): + user_res = select_options(f'Pick {output} resolution: ', resolutions) + user_freq = None + for freq_lst in freqs: + if freq_lst[0] == user_res: + user_freq = select_options(f'Pick refresh rate: ', freq_lst[1:]) + monitor_set[output] = {"resolution": user_res, "freq": user_freq} + +print("Setup monitor locations...") +print("Avaiable monitors") +for output in outputs: + print(output) + +if len(outputs) == 1: + print("skipping input only one monitor...") + first_key = list(monitor_set)[0] + os.system("xrandr --output %s --mode %s --rate %s --primary"%( + outputs[0], + monitor_set[first_key]['resolution'], + monitor_set[first_key]['freq']) + ) + +elif len(outputs) == 2: + left = input('which monitor is on the left? ') + if left not in outputs: + # crash + 0/0 + outputs.remove(left) + right = outputs[0] + left_primary = input('is left primary? (y or n) ') + + left_pri_str = "--primary" if left_primary == 'y' else "" + right_pri_str = "--primary" if left_primary == 'n' else "" + + cmd_str = "xrandr --output %s --mode %s --pos 0x0 --rate %s %s --output %s --mode %s --pos 2561x0 --rate %s %s --right-of %s"%( + left, + monitor_set[left]['resolution'], + monitor_set[left]['freq'], + left_pri_str, + right, + monitor_set[right]['resolution'], + monitor_set[right]['freq'], + right_pri_str, + left + ) + print(cmd_str) + os.system(cmd_str) + +else: + #crash + 0/0 + + +os.system("autorandr --save current --force") + +if len(list(monitor_set)) == 1: + i3_dict["disp_pri"] = list(monitor_set)[0] + i3_dict["disp_sec"] = list(monitor_set)[0] +else: + i3_dict["disp_pri"] = left if left_primary == 'y' else right + i3_dict["disp_sec"] = left if left_primary == 'n' else right + +print(i3_dict["disp_pri"], i3_dict["disp_sec"]) + +# write result to json +p = pathlib.PosixPath('~/.local/share/chezmoi/home/.gen/i3.json').expanduser() +p.parent.mkdir(parents=True, exist_ok=True) +with open(p, 'w') as f: + json.dump(i3_dict, f, indent=4, sort_keys=True) diff --git a/home/bin/executable_linux-monitor.tmpl b/home/bin/executable_linux-monitor.tmpl deleted file mode 100644 index 560d25c0..00000000 --- a/home/bin/executable_linux-monitor.tmpl +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/python -# -import subprocess -import json -import pathlib -import os - -# save needed information in a dictionary -i3_dict = {} - -cmd = str(subprocess.check_output("xrandr", shell=True)) -outputs = [] - -for row in cmd.split('\\n'): - if " connected" in row: - outputs.append(row.split(" ")[0]) - -print("Available monitors:") -for output in outputs: - print(output) - -if len(outputs) == 1: - print("skipping input only one monitor...") - os.system("xrandr --output %s --mode 2560x1440 --rate 144 --primary"%(outputs[0])) -elif len(outputs) == 2: - left = input('which monitor is on the left? ') - if left not in outputs: - # crash - 0/0 - outputs.remove(left) - right = outputs[0] - left_primary = input('is left primary? (y or n) ') - - left_pri_str = "--primary" if left_primary == 'y' else "" - right_pri_str = "--primary" if left_primary == 'n' else "" - - cmd_str = "xrandr --output %s --mode 2560x1440 --pos 0x0 --rate 144 %s --output %s --mode 2560x1440 --pos 2561x0 --rate 144 %s --right-of %s"%(left, left_pri_str, right, right_pri_str, left) - print(cmd_str) - os.system(cmd_str) - -else: - #crash - 0/0 - - -os.system("autorandr --save current --force") - -# ask user to define primary and secondary monitor -i3_dict["disp_pri"] = left if left_primary == 'y' else right -i3_dict["disp_sec"] = left if left_primary == 'n' else right - -print(i3_dict["disp_pri"], i3_dict["disp_sec"]) - -# write result to json -p = pathlib.Path('{{ .chezmoi.sourceDir }}/.gen/i3.json') -p.parent.mkdir(parents=True, exist_ok=True) -with open(p, 'w') as f: - json.dump(i3_dict, f, indent=4, sort_keys=True) diff --git a/home/bin/executable_void-initial-setup.tmpl b/home/bin/executable_void-initial-setup.tmpl deleted file mode 100644 index e8d68254..00000000 --- a/home/bin/executable_void-initial-setup.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -echo -e "Starting initial setup..." - -# Install ansible python dependencies -sudo xpbs-install -Syu -y -sudo xbps-install python3 python3-pip ansible -y -sudo pip install pexpect github3.py -y - -# Install ansible extensions -ansible-galaxy install -r {{ .chezmoi.workingTree }}/provision/requirements.yml - -# Goto playbook and run it -cd {{ .chezmoi.workingTree }}/provision -ansible-playbook setup.yml -i hosts --ask-become-pass - -# Return to where you were -cd - - -echo "I'd suggest rebooting" diff --git a/home/dot_config/alacritty/alacritty.yml b/home/dot_config/alacritty/alacritty.yml index 76ce36f3..4e800c27 100644 --- a/home/dot_config/alacritty/alacritty.yml +++ b/home/dot_config/alacritty/alacritty.yml @@ -50,4 +50,4 @@ font: y: 0 import: - - /home/tstarr/.config/alacritty/dracula.yml + - ~/.config/alacritty/dracula.yml diff --git a/home/dot_config/chezmoi/chezmoi.toml b/home/dot_config/chezmoi/chezmoi.toml deleted file mode 100644 index b09f2176..00000000 --- a/home/dot_config/chezmoi/chezmoi.toml +++ /dev/null @@ -1,2 +0,0 @@ -[secret] - command = "rbw-get" diff --git a/home/dot_config/polybar/dracula.tmpl b/home/dot_config/polybar/dracula.tmpl index c1089165..1a4961de 100644 --- a/home/dot_config/polybar/dracula.tmpl +++ b/home/dot_config/polybar/dracula.tmpl @@ -62,7 +62,7 @@ label-font = 2 [module/wlan] type = internal/network -interface = enp3s0 +interface = {{ .network_interface }} interval = 5 label-connected = 直 %local_ip% label-connected-foreground = "#50fa7b" @@ -72,7 +72,7 @@ content-padding = 2 [module/bandwidth] type = internal/network -interface = enp3s0 +interface = {{ .network_interface }} interval = 5 label-connected =  %downspeed%  %upspeed% label-disconnected = diff --git a/home/dot_zshrc b/home/dot_zshrc index b8e033f2..80c43b06 100644 --- a/home/dot_zshrc +++ b/home/dot_zshrc @@ -10,7 +10,7 @@ export ZSH="$HOME/.oh-my-zsh" # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes -ZSH_THEME="dracula" +ZSH_THEME="dracula/dracula" # Set list of themes to pick from when loading at random # Setting this variable when ZSH_THEME=random will cause zsh to load diff --git a/jumpstart.sh b/jumpstart.sh new file mode 100755 index 00000000..368f2725 --- /dev/null +++ b/jumpstart.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +echo -e "Starting initial setup..." + +CHEZDIR="/home/test/.local/share/chezmoi" +echo "Input email for bitwarden:" +read bitemail + +# Install ansible python dependencies +sudo xbps-install -Syu -y +sudo xbps-install python3 python3-pip ansible -y +sudo pip install pexpect + +# Install ansible extensions +ansible-galaxy install -r "$CHEZDIR/provision/requirements.yml" + +# Run setup playbook +ansible-playbook "$CHEZDIR/provision/setup.yml" -i "$CHEZDIR/provision/hosts" --ask-become-pass + +#export PATH="$PATH:/usr/local/bin" + +# Copy jumpstart scripts to temp bin dir and add to path +mkdir -p "$CHEZDIR/temp_bin" +cp "$CHEZDIR/home/bin/executable_rbw-get" "$CHEZDIR/temp_bin/rbw-get" +chmod +x "$CHEZDIR/temp_bin/rbw-get" +export PATH="$PATH:$CHEZDIR/temp_bin" + +# Set bitwarden email +rbw config set email "$bitemail" + +# Make temporary i3 gen file +mkdir -p "$CHEZDIR/home/.gen" +echo "{ + \"disp_pri\": \"HDMI-0\", + \"disp_sec\": \"HDMI-0\" +}" > "$CHEZDIR/home/.gen/i3.json" + +# first chezmoi apply +chezmoi apply + +# reboot! +read -p "You should reboot, but I won't make you. Reboot? " -n 1 -r +if [[ ! $REPLY =~ ^[Yy]$ ]] +then + exit 1 +fi + +sudo reboot + diff --git a/provision/setup.yml b/provision/setup.yml index e6ecc457..9fcc36d0 100644 --- a/provision/setup.yml +++ b/provision/setup.yml @@ -2,7 +2,7 @@ hosts: all vars_files: - - vars/main.yml + - ../home/.chezmoidata.yaml tasks: - import_tasks: tasks/system/_main.yml @@ -10,4 +10,5 @@ - import_tasks: tasks/development/_main.yml - import_tasks: tasks/desktop/_main.yml - import_tasks: tasks/gaming/_main.yml + - import_tasks: tasks/engineering/_main.yml diff --git a/provision/tasks/desktop/packages.yml b/provision/tasks/desktop/packages.yml index 7e148519..a4b54597 100644 --- a/provision/tasks/desktop/packages.yml +++ b/provision/tasks/desktop/packages.yml @@ -27,6 +27,7 @@ - xsel # Command-line getting and setting the contents of the X selection - clipmenu # Clipboard management using dmenu - nerd-fonts # Iconic font aggregator, collection and patcher + - xdotool # Command-line X11 automation tool state: present become: true diff --git a/provision/tasks/system/configs.yml b/provision/tasks/system/configs.yml index 752ee3be..ee6bd052 100644 --- a/provision/tasks/system/configs.yml +++ b/provision/tasks/system/configs.yml @@ -13,3 +13,74 @@ group: root mode: 0775 become: true + +- name: Set git username and email + shell: | + git config --global user.email {{ git_email }} + git config --global user.name {{ git_user }} + +- name: Start system services + shell: | + ln -s /etc/sv/dbus /var/service + ln -s /etc/sv/polkitd /var/service + ln -s /etc/sv/bluetoothd /var/service + ln -s /etc/sv/sshd /var/service + ln -s /etc/sv/libvirtd /var/service + ln -s /etc/sv/virtlockd /var/service + ln -s /etc/sv/virtlogd /var/service + ignore_errors: true + become: true + +- name: Add {{ user }} to libvirt group + shell: | + gpasswd -a {{ user }} libvirt + become: true + +- name: Setup user services + block: + - name: Create user folder + file: + path: /etc/sv/{{ user }} + state: directory + + - name: Create user service file + copy: + dest: /etc/sv/{{ user }}/run + content: | + #!/bin/sh + USER="{{ user }}" + GROUPS="$(id -Gn "$USER" | tr ' ' ':')" + SVDIR="/home/${USER}/.service" + if [ -d ${SVDIR} ]; then + chpst -u"${USER}:${GROUPS}" runsvdir ${SVDIR} + fi + mode: 0755 + + - name: Enable user services + shell: | + ln -s /etc/sv/{{ user }} /var/service + ignore_errors: true + become: true + +- name: Ensure user services folder exists + file: + path: /home/{{ user }}/.service + state: directory + mode: 0755 + +- name: Start syncthing as {{ user }} + block: + - name: Create syncthing folder + file: + path: /home/{{ user }}/.service/syncthing + state: directory + mode: 0755 + + - name: Create synthing run file + copy: + dest: /home/{{ user }}/.service/syncthing/run + content: | + #!/bin/sh + export HOME=/home/{{ user }}/ + exec /usr/bin/syncthing > /dev/null 2>&1 + mode: 0755 diff --git a/provision/tasks/system/packages.yml b/provision/tasks/system/packages.yml index 41a0d861..5969fcc9 100644 --- a/provision/tasks/system/packages.yml +++ b/provision/tasks/system/packages.yml @@ -32,6 +32,7 @@ - libvirt # Virtualization API for controlling virtualization engines - virt-manager # User interface for managing virtual machines - bridge-utils # Layer2 ethernet bridging for Linux + - trash-cli # Command line interface to the freedesktop.org trashcan state: present become: true diff --git a/provision/tasks/terminal/_main.yml b/provision/tasks/terminal/_main.yml index 68d12ab3..b527d4d1 100644 --- a/provision/tasks/terminal/_main.yml +++ b/provision/tasks/terminal/_main.yml @@ -1,2 +1,4 @@ - import_tasks: packages.yml tags: ["packages"] +- import_tasks: configs.yml + tags: ["configs"] diff --git a/provision/tasks/terminal/configs.yml b/provision/tasks/terminal/configs.yml new file mode 100644 index 00000000..2bed2f40 --- /dev/null +++ b/provision/tasks/terminal/configs.yml @@ -0,0 +1,10 @@ +- name: change {{ user }} shell to zsh + user: + name: "{{ user }}" + shell: /bin/zsh + become: true + + +- name: Set rbw email + shell: | + rbw config set email {{ bitwarden_email }} diff --git a/provision/tasks/terminal/nb.yml b/provision/tasks/terminal/nb.yml index ffe79da4..fd296970 100644 --- a/provision/tasks/terminal/nb.yml +++ b/provision/tasks/terminal/nb.yml @@ -4,7 +4,3 @@ dest: /usr/local/bin/nb mode: 0755 become: true - -- name: Setup nb completions - command: nb completions install --download - become: true diff --git a/provision/vars/main.yml b/provision/vars/main.yml deleted file mode 100644 index 6aec41d5..00000000 --- a/provision/vars/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -user: tstarr -hostname: kestrel -desktop: i3 # valid values: i3, gnome diff --git a/readme.md b/readme.md index 7e9257dd..99dfb707 100644 --- a/readme.md +++ b/readme.md @@ -5,33 +5,32 @@ My personal dotfiles repo. Documentation is pretty spotty. Maybe I'll fix that s ## Usage -Dotfiles are managed with stow and Ansible (built for Fedora) is used for the bulk of configuration. Setup that cannot be easily automated with Ansible is documentd in [addtional-setup](additional-setup.md). +Dotfiles are managed with chezmoi and Ansible (built for Void) is used for the bulk of configuration. ## Initial Setup -Install Fedora Workstation and run the following commands: +Install Void with BTRFS and run the following commands: ```bash -sudo dnf install -y git stow -git clone https://github.com/starr-dusT/dotfiles ~/.dotfiles -rm ~/.bashrc -cd ~/.dotfiles && stow . -bash -initial-setup +sudo xbps-install -Syu -y +sudo xbps-install -S git chezmoi -y +git clone https://github.com/starr-dusT/dotfiles ~/.local/share/chezmoi ``` +Then edit the `.chezmoidata.yaml` file within `home` to desired settings and run the following commands: + +```bash +~/.local/share/chezmoi/jumpstart.sh +``` + +After reboot log into window manager and run `linux-monitor`, follow the prompts, reapply chezmoi config, and restart the window manager. + Perform additional setup found in [additional-setup](additional-setup.md) ## Update Setup -Run the following command with comma seperated tags: - -```bash -update {tags} # valid tags: configs, updates, packages, services, once -``` +`void-update` command updates the system with ansible. Run `void-update -h` for information on usage. ## TODO -- make homesever use btrfs and fix "target" for home backups -- Add zsh with workable config - setup pavucontrol and bluetooth with scratchpads, polybar integration, etc. diff --git a/void.md b/void.md index 97f76f37..1a47a0b0 100644 --- a/void.md +++ b/void.md @@ -1,112 +1,3 @@ -## enable dbus - -```bash -sudo ln -s /etc/sv/dbus /var/service -``` -## enable polkitd - -```bash -sudo ln -s /etc/sv/polkitd /var/service -``` - -## enable bluetooth - -```bash -sudo ln -s /etc/sv/bluetoothd /var/service -``` - -## enable sshd - -```bash -sudo ln -s /etc/sv/sshd /var/service -``` - -## enable virt stuff - -```bash -sudo ln -s /etc/sv/libvirtd /var/service -sudo ln -s /etc/sv/virtlockd /var/service -sudo ln -s /etc/sv/virtlogd /var/service -``` -add user to group: -```bash -sudo gpasswd -a "$USER" libvirt -``` - -## enable non-free and multilib - -```bash -xbps-install -Syv void-repo-nonfree -xbps-install -Syv void-repo-multilib -xbps-install -Syv void-repo-multilib-nonfree -``` - -## void packages - -```bash -$ git clone https://github.com/void-linux/void-packages.git -$ cd void-packages -$ ./xbps-src binary-bootstrap -echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf - -# Example install discord -./xbps-src pkg discord -sudo xbps-install --repository hostdir/binpkgs/nonfree discord -``` - -## user services - -```bash -sudo mkdir -p /etc/sv/tstarr -sudo touch /etc/sv/tstarr/run -sudo chmod +x /etc/sv/tstarr/run -``` - -Add following: - -```bash -#!/bin/sh - -USER="tstarr" -GROUPS="$(id -Gn "$USER" | tr ' ' ':')" -SVDIR="/home/${USER}/.service" - - -if [ -d ${SVDIR} ]; then - chpst -u"${USER}:${GROUPS}" runsvdir ${SVDIR} -fi -``` - -```bash -sudo ln -s /etc/sv/tstarr /var/service -``` - -Example with syncthing: - -```bash -mkdir -p $HOME/.service/syncthing -touch $HOME/.service/syncthing/run -chmod +x $HOME/.service/syncthing/run -``` - -Add the following: - -```bash -#!/bin/sh - -export HOME=/home/tstarr/ -exec /usr/bin/syncthing > /dev/null 2>&1 -``` - ## Lxappearance GTK theme can be set with lxappearance - -## poweroff without root - -add to /etc/sudoers: - -```bash -tstarr ALL=NOPASSWD:/bin/poweroff -``` -