mirror of
https://github.com/starr-dusT/dotfiles.git
synced 2025-02-19 19:27:31 -08:00
remove cruft from bin scripts
This commit is contained in:
parent
d61ef80e95
commit
532a053a9e
@ -1,107 +0,0 @@
|
|||||||
#!/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)
|
|
@ -1,71 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
help ()
|
|
||||||
{
|
|
||||||
echo "
|
|
||||||
Update void linux with ansible
|
|
||||||
|
|
||||||
Usage: update <tags> <flags>
|
|
||||||
|
|
||||||
EXAMPLE TAGS:
|
|
||||||
packages,configs
|
|
||||||
|
|
||||||
FLAGS:
|
|
||||||
-f, --fedora perform update for fedora
|
|
||||||
-a, --arch perform update for arch
|
|
||||||
-v, --void perform update for void
|
|
||||||
-s, --src compile (or recompile) source based packages"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
POSITIONAL_ARGS=()
|
|
||||||
SRC=false
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
-v|--void)
|
|
||||||
distro="void"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-a|--arch)
|
|
||||||
distro="arch"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-f|--fedora)
|
|
||||||
distro="fedora"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-s|--src)
|
|
||||||
SRC=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-h|--help)
|
|
||||||
help
|
|
||||||
;;
|
|
||||||
-*|--*)
|
|
||||||
echo "Unknown option $1"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
POSITIONAL_ARGS+=("$1")
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
|
|
||||||
|
|
||||||
# Goto playbook and run it
|
|
||||||
cd "{{ .chezmoi.workingTree }}/provision/$distro/ansible"
|
|
||||||
|
|
||||||
# Install ansible and run playbook
|
|
||||||
if [ "$SRC" = true ] ; then
|
|
||||||
echo "Starting update with source packages - be prepated to wait..."
|
|
||||||
ansible-playbook setup.yml -i hosts --ask-become-pass --tags "$1" --skip-tags "once"
|
|
||||||
else
|
|
||||||
echo "Starting update without source packages..."
|
|
||||||
ansible-playbook setup.yml -i hosts --ask-become-pass --tags "$1" --skip-tags "once,src"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Return to where you were
|
|
||||||
cd - > /dev/null
|
|
@ -1,11 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# rbw-get <name of entry> <field of entry>
|
|
||||||
# Ex: rbw-get google url
|
|
||||||
|
|
||||||
if [[ "$2" == "Password" ]]
|
|
||||||
then
|
|
||||||
rbw get "$1"
|
|
||||||
else
|
|
||||||
rbw get "$1" --field="$2"
|
|
||||||
fi
|
|
@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
if [[ $(task "$1" +grocery 2>&1) == "No matches." ]];
|
|
||||||
then
|
|
||||||
date_str=$(date +"_%Y%m%d_%H:%M:%S")
|
|
||||||
filename="$HOME/documents/warrior/fleeting/grocery${date_str}.md"
|
|
||||||
cp "$HOME/documents/warrior/templates/grocery.md" "${filename}"
|
|
||||||
task "$1" modify +grocery
|
|
||||||
task "$1" annotate "${filename}"
|
|
||||||
taskopen $1
|
|
||||||
else
|
|
||||||
taskopen $1
|
|
||||||
fi
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
if [[ $(task "$1" +fleeting 2>&1) == "No matches." ]];
|
|
||||||
then
|
|
||||||
task "$1" modify +fleeting
|
|
||||||
task "$1" annotate fleeting
|
|
||||||
taskopen $1
|
|
||||||
else
|
|
||||||
taskopen $1
|
|
||||||
fi
|
|
@ -1,22 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
|
|
||||||
input_str = sys.stdin.read().replace("\n", "")
|
|
||||||
pkg = input_str.replace(" ", "")[1:]
|
|
||||||
cmd = "xbps-query -Rs %s"%(pkg)
|
|
||||||
output = subprocess.getoutput(cmd)
|
|
||||||
if output.count('[') > 1:
|
|
||||||
cmd = "xbps-query -Rs %s | grep -E ' %s-[0-9](.|[0-9])[0-9]'"%(pkg,pkg)
|
|
||||||
output = subprocess.getoutput(cmd)
|
|
||||||
upper_pos = -1
|
|
||||||
for index, char in enumerate(output):
|
|
||||||
if char == char.upper() and char.isalpha():
|
|
||||||
upper_pos = index
|
|
||||||
break
|
|
||||||
if upper_pos == -1:
|
|
||||||
sys.stdout.write("error")
|
|
||||||
else:
|
|
||||||
sys.stdout.write(input_str + " # " + output[upper_pos:])
|
|
Loading…
x
Reference in New Issue
Block a user