]> us-delaporte.pagekite.me Git - dotfiles.git/blob - files/pc/tasks.py
Add helper to setup favorite virtual environments
[dotfiles.git] / files / pc / tasks.py
1 # This file is meant to sit in ~ for use from all shells.
2 from invoke import task
3
4 from datetime import datetime as dt
5 import os
6
7 HOME = os.path.expanduser('~')
8 TODAY = dt.now().strftime('%Y.%m.%d')
9 KIDS_ALLOWANCE_URL=os.environ.get('KIDS_ALLOWANCE_URL')
10 PAYROLL = os.environ.get('PAYROLL')
11 BUDGET_URL = os.environ.get('BUDGET_URL')
12 CU_URL = os.environ.get('CU_URL')
13 SCHOOL = f"{HOME}/School"
14 PAYROLL = f"{HOME}/Nanny.Payroll"
15
16
17
18
19 def browse(c, url):
20 c.run(f"librefox {url}", asynchronous=True)
21
22
23 def code(c, path):
24 c.run(f"codium {path}")
25
26
27 def folder(c, path):
28 c.run(f"nemo {path}")
29
30 @task
31 def go(c, bookmark):
32 var = f'URL_{bookmark.upper()}'
33 url = os.environ.get(var)
34 browse(c, url)
35
36 @task
37 def cloud_panel(c):
38 go(c, 'cloud')
39
40 @task
41 def debug(c):
42 result = c.run('which minetest')
43 print(result.ok)
44
45
46 @task
47 def fix_mouse(c):
48 c.run('xinput --disable 18')
49 c.run('xinput --enable 18')
50
51
52 @task
53 def fix_invoke_complete(c):
54 c.run('invoke --print-completion-script bash > ~/.invoke-complete.sh')
55
56 @task
57 def temp(c):
58 c.run('sensors')
59
60
61
62 def term(c, path):
63 c.run(f'konsole --separate --workdir {path}', asynchronous=True)
64
65 def browse(c, url):
66 c.run(f"librewolf {url}", asynchronous=True)
67
68
69 def code(c, path):
70 c.run(f"codium {path}")
71
72
73 def folder(c, path):
74 c.run(f'dolphin {path}', asynchronous=True)
75 # c.run(f"nemo {path}")
76
77
78 @task
79 def debug(c):
80 result = c.run('which minetest')
81 print(result.ok)
82
83
84 @task
85 def allowance(c):
86 browse(c, KIDS_ALLOWANCE_URL)
87
88
89 @task
90 def payroll(c):
91
92 allowance(c)
93
94 # For copying the latest file in
95 folder(c, f"{HOME}/pixel7adocuments")
96 folder(c, f"{PAYROLL}/data/payroll_inbox")
97
98 # For editing files
99 folder_payroll(c)
100 payroll_jupyter(c)
101
102 @task
103 def payroll_jupyter(c):
104
105 # For running the payroll scripts
106 c.run(f"cd {PAYROLL};{HOME}/envs/jupyter/bin/jupyter-lab")
107
108 @task
109 def folder_payroll(c):
110 code(c, f"{PAYROLL}")
111
112
113 @task()
114 def screenshare(c):
115 browse(c, 'https://app.screego.net/#/')
116 c.run('dino')
117
118 @task
119 def show_free_space(c):
120 c.run('df -h | grep G') # We only care about disks measured in G
121
122 @task()
123 def free_disk_space(c, ruthless=False):
124 show_free_space(c)
125 c.run('podman container cleanup --all --rm')
126 # Dolphin Trash ...should regenerate
127 c.run(f'sudo rm -rf {HOME}/.local/share/Trash')
128 # c.run(f'rm {HOME}/Downloads/*.iso')
129 c.run('sudo apt-get autoclean') # Remove useless apt cache
130 if ruthless:
131 c.run(f'rm -rf {HOME}/Downloads/*')
132 c.run('sudo apt-get clean') # Remove all apt cache
133 show_free_space(c)
134
135 @task
136 def assign_school(c):
137 term(c, f'{SCHOOL}')
138
139 @task
140 def mod_luanti(c):
141 print("https://rubenwardy.com/minetest_modding_book/en/quality/luacheck.html")
142 term(c, f'{HOME}/.var/app/net.minetest.Minetest/.minetest')
143
144
145 @task
146 def budget(c):
147 browse(c, BUDGET_URL)
148 browse(c, CU_URL)
149
150
151 @task
152 def get_drive_info(c):
153 # List non-squash, non-tmp drives.
154 c.run('df -x squashfs -x tmpfs')
155 c.run('ls /dev/disk/by-label')
156
157