-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.py
executable file
·106 lines (84 loc) · 3.81 KB
/
install.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#! /usr/bin/env python3
import os, shutil, subprocess, sys
# All pacman packages that are required for this ocnfiguration to run
PKG_DEPS = {
'dex': 'launches all autostart desktop files',
'inter-font': 'Font used for interface',
'libyaml': 'required for lua yaml lib to read config',
'light-locker': 'required to lock screen properly',
'luarocks': 'installs lua dependencies',
'playerctl': 'required for music player and media hotkeys',
'xautolock': 'lock screen automatically after timeout',
'xdg-utils': 'starts files according to their extension',
'xorg-setxkbmap': 'changes the keyboard layout',
'xorg-xset': 'sets properties in xserver (e.g. power saving)',
'yarn': 'required to build typescript files',
}
# All optional dependencies. These won't be installed automatically, but information
# will be printed out at the end of this script.
OPT_PKG_DEPS = {
'cpupower': 'required to show CPU frequency information in sidebar',
'flameshot': 'required to take screenshots',
'numlockx': 'install to enable numlock on start',
'picom': 'required if you want compositing effects (e.g. shadow)',
'rojimoji': 'optional to get an emoji picker',
'upower': 'required for battery widget',
'xf86-input-libinput': 'required for better touchpad behavior',
'xorg-xinput': 'required to configure mouse and trackpads',
'xorg-xrandr': 'required for displayswitcher',
'xorg-xrdb': 'required to set dpi for some applications in displayswitcher'
}
# List all packages that should be installed via luarocks
LUA_DEPS = {
'inifile': 'required to parse ini files (used in icon themes)',
'inspect': 'required for debugging tables',
'luafilesystem': 'required to interact with the filesystem',
'lyaml': 'YAML library to read out config',
}
# Colors
BLUE = "\033[1;34m"
GREEN = "\033[1;32m"
RESET = "\033[0;0m"
BOLD = "\033[;1m"
def install_pkg_deps():
for dep, desc in PKG_DEPS.items():
print(' {}{}{} - {}'.format(BOLD, dep, RESET, desc))
print('')
subprocess.call(['sudo', 'pacman', '-S', '--needed'] + list(PKG_DEPS.keys()))
def install_lua_deps():
for dep, desc in LUA_DEPS.items():
print(' {}{}{} - {}'.format(BOLD, dep, RESET, desc))
print('')
for dep, desc in LUA_DEPS.items():
subprocess.call(['luarocks', '--local', '--lua-version', '5.3', 'install', dep])
def install_yarn_deps():
subprocess.call(['yarn', 'install'])
def build_typescript():
subprocess.call(['yarn', 'build'])
def print_opt_pkg_info():
print('{}Optional packages{}\n'.format(BLUE, RESET))
print('The following packages are optional and only required for specific features.')
print('Install them manually if you want to use the features.\n')
FNULL = open(os.devnull, 'w')
for dep, desc in OPT_PKG_DEPS.items():
installed = not subprocess.call(['pacman', '-Qq', dep], stdout=FNULL, stderr=FNULL)
print(' {}{}{}{} - {}'.format(BOLD, dep, RESET, f' {GREEN}[already installed]{RESET}' if installed else '', desc))
if __name__ == '__main__':
if not shutil.which('pacman'):
print('This install script requires pacman as package manager.')
print('Please look into it and install all required dependencies manually.')
sys.exit(1)
print('{}Installing package dependencies:{}\n'.format(BLUE, RESET))
install_pkg_deps()
print('{}Finished installing package dependencies.{}\n'.format(GREEN, RESET))
print('{}Installing lua dependencies:{}\n'.format(BLUE, RESET))
install_lua_deps()
print('{}Finished installing lua dependencies.{}\n'.format(GREEN, RESET))
print('{}Installing npm dependencies:{}\n'.format(BLUE, RESET))
install_yarn_deps()
print('{}Finished installing npm dependencies.{}\n'.format(GREEN, RESET))
print('{}Compiling TypeScript to Lua:{}\n'.format(BLUE, RESET))
build_typescript()
print('{}Finished compiling TypeScript.{}\n'.format(GREEN, RESET))
print_opt_pkg_info()
print('')