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