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