update README and initial script

This commit is contained in:
Tyler Starr 2022-12-30 11:51:39 -08:00
parent f0b340c00d
commit bb10482ad6
23 changed files with 275 additions and 225 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.gen
temp_bin

2
home/.chezmoi.yaml.tmpl Normal file
View File

@ -0,0 +1,2 @@
secret:
command: "rbw-get"

7
home/.chezmoidata.yaml Normal file
View File

@ -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

View File

@ -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"]

View File

@ -1,3 +1,4 @@
.oh-my-zsh/cache/**
readme.md
.gitignore
.git

View File

@ -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)

View File

@ -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)

View File

@ -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"

View File

@ -50,4 +50,4 @@ font:
y: 0
import:
- /home/tstarr/.config/alacritty/dracula.yml
- ~/.config/alacritty/dracula.yml

View File

@ -1,2 +0,0 @@
[secret]
command = "rbw-get"

View File

@ -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 =

View File

@ -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

49
jumpstart.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,2 +1,4 @@
- import_tasks: packages.yml
tags: ["packages"]
- import_tasks: configs.yml
tags: ["configs"]

View File

@ -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 }}

View File

@ -4,7 +4,3 @@
dest: /usr/local/bin/nb
mode: 0755
become: true
- name: Setup nb completions
command: nb completions install --download
become: true

View File

@ -1,3 +0,0 @@
user: tstarr
hostname: kestrel
desktop: i3 # valid values: i3, gnome

View File

@ -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.

109
void.md
View File

@ -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
```