forked from cameron-simpson/css
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesktop.py
More file actions
51 lines (44 loc) · 1.36 KB
/
Copy pathdesktop.py
File metadata and controls
51 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
''' Utilities for managing my desktop - wallpapers, etc.
'''
from dataclasses import dataclass, field
import os
from os.path import expanduser
from cs.debug import trace
@dataclass
class Desktop:
''' Information about the desktop.
'''
SSV_DEFAULT = '~/im/screencaps'
SSV_ENVVAR = 'SSV_DIR'
WPDIR_DEFAULT = '~/im/wp'
WPDIR_ENVVAR = 'WPDIR'
WPLINKDIR_DEFAULT = '~/var/im/wp'
WPLINKDIR_ENVVAR = 'WPLINKDIR'
WPPATH_ENVVAR = 'WPPATH'
# directory containing screenshot collections
ssvdirpath: str = field(
default_factory=lambda: os.environ.
get(Desktop.SSV_ENVVAR, expanduser(Desktop.SSV_DEFAULT))
)
# directory containing wallpaper collections
wpdirpath: str = field(
default_factory=lambda: os.environ.
get(Desktop.WPDIR_ENVVAR, expanduser(Desktop.WPDIR_DEFAULT))
)
# directory where wallpaper selection subdirectories are made
wplinkdirpath: str = field(
default_factory=lambda: os.environ.
get(Desktop.WPLINKDIR_ENVVAR, expanduser(Desktop.WPLINKDIR_DEFAULT))
)
# the wallpaper search path
wppath: str = None
def __post_init__(self):
if self.wppath is None:
try:
wppath = os.environ[Desktop.WPPATH_ENVVAR]
except KeyError:
self.wppath = [self.wpdirpath, self.ssvdirpath]
else:
self.wppath = wppath.split(os.pathsep)
print("Desktop", self)