]> us-delaporte.pagekite.me Git - dotfiles.git/blob - files/pc/tasks.py
Update help text
[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 PAYROLL = os.environ.get('PAYROLL')
10 SCHOOL = f"{HOME}/School"
11
12 expect_URLs = [
13 'budget',
14 'cu',
15 'allowance'
16 ]
17
18 expect_PATHs = [
19 'podcasts',
20 ]
21
22
23
24 URLS = {}
25 for url in expect_URLs:
26 key = f'URL_{url.upper()}'
27 result = os.environ.get(key)
28 if not result:
29 print(f'Missing expected {key} in environment.')
30 # raise ValueError(f'Missing expected {key} in environment.')
31 URLS[url] = result
32
33
34 PATHS = {}
35 for path in expect_PATHs:
36 key = f'PATH_{path.upper()}'
37 result = os.environ.get(key)
38 if not result:
39 print(f'Missing expected {key} in environment.')
40 PATHS[path] = result
41
42
43 def browse(c, url):
44 c.run(f"librefox {url}", asynchronous=True)
45
46
47 def code(c, path):
48 c.run(f"codium {path}")
49
50
51 def folder(c, path):
52 c.run(f"nemo {path}")
53 c.run(f"dolphin {path}")
54
55 @task
56 def go(c, bookmark):
57 var = f'URL_{bookmark.upper()}'
58 url = os.environ.get(var)
59 browse(c, url)
60
61 @task
62 def cloud_panel(c):
63 go(c, 'cloud')
64
65 @task
66 def debug(c):
67 result = c.run('which minetest')
68 print(result.ok)
69
70
71 @task
72 def fix_mouse(c):
73 c.run('xinput --disable 18')
74 c.run('xinput --enable 18')
75
76
77 @task
78 def fix_invoke_complete(c):
79 c.run('invoke --print-completion-script bash > ~/.invoke-complete.sh')
80
81 @task
82 def temp(c):
83 c.run('sensors')
84
85
86
87 def term(c, path):
88 c.run(f'konsole --separate --workdir {path}', asynchronous=True)
89
90 def browse(c, url):
91 c.run(f"librewolf {url}", asynchronous=True)
92
93
94 def code(c, path):
95 c.run(f"codium {path}")
96
97
98 def folder(c, path):
99 c.run(f'dolphin {path}', asynchronous=True)
100 # c.run(f"nemo {path}")
101
102
103 @task
104 def debug(c):
105 result = c.run('which minetest')
106 print(result.ok)
107
108
109 @task
110 def allowance(c):
111 browse(c, URLS['allowance'])
112
113 @task
114 def payroll_folders(c):
115 # For copying the latest file in
116 folder(c, f"{HOME}/pixel7adocuments")
117 folder(c, f"{PAYROLL}/data/payroll_inbox")
118 folder(c, f"{PAYROLL}")
119
120
121 @task
122 def payroll(c):
123
124 allowance(c)
125 payroll_folders(c)
126
127 # For editing files
128 code(c, f"{PAYROLL}")
129 print("Use Invoke")
130
131 @task()
132 def screenshare(c):
133 browse(c, 'https://app.screego.net/#/')
134 c.run('dino')
135
136 @task
137 def show_free_space(c):
138 c.run('df -h | grep G') # We only care about disks measured in G
139
140 @task()
141 def free_disk_space(c, ruthless=False):
142 show_free_space(c)
143 c.run('podman container cleanup --all --rm')
144 # Dolphin Trash ...should regenerate
145 c.run(f'sudo rm -rf {HOME}/.local/share/Trash')
146 # c.run(f'rm {HOME}/Downloads/*.iso')
147 c.run('sudo apt-get autoclean') # Remove useless apt cache
148 if ruthless:
149 c.run(f'rm -rf {HOME}/Downloads/*')
150 c.run('sudo apt-get clean') # Remove all apt cache
151 show_free_space(c)
152
153 @task
154 def assign_school(c):
155 term(c, f'{SCHOOL}')
156
157 @task
158 def mod_luanti(c):
159 print("https://rubenwardy.com/minetest_modding_book/en/quality/luacheck.html")
160 term(c, f'{HOME}/.var/app/net.minetest.Minetest/.minetest')
161
162
163 @task
164 def budget(c):
165 browse(c, URLS['budget'])
166 browse(c, URLS['cu'])
167
168
169 @task
170 def get_drive_info(c):
171 # List non-squash, non-tmp drives.
172 c.run('df -x squashfs -x tmpfs')
173 c.run('ls /dev/disk/by-label')
174
175
176 @task
177 def podcasts(c):
178 folder(c, PATHS['podcasts'])
179
180 @task
181 def matrix(c):
182 c.run('gomuks')