()
| 48 | |
| 49 | |
| 50 | def install(): |
| 51 | package_dir = os.path.join(os.path.dirname(__file__), "..") |
| 52 | |
| 53 | # Guard against users potentially running this script from the wrong directory |
| 54 | os.chdir(package_dir) |
| 55 | |
| 56 | # Where gnome-shell extensions live |
| 57 | install_directory = os.path.expanduser("~/.local/share/gnome-shell/extensions") |
| 58 | # Under what name we want to install the extension as |
| 59 | install_name = "material-shell@papyelgringo" |
| 60 | install_path = os.path.join(install_directory, install_name) |
| 61 | |
| 62 | # This folder contains all the compiled code and assets. |
| 63 | # Note that this must be relative at this point because this whole directory |
| 64 | # may be moved (see below) |
| 65 | dist_dir = "./dist" |
| 66 | |
| 67 | # Check if node and npm are installed |
| 68 | if which("npm") is None: |
| 69 | printc(RED, "npm could not be found. You need to install npm to build material-shell. See https://www.npmjs.com/get-npm") |
| 70 | exit(1) |
| 71 | |
| 72 | if which("node") is None: |
| 73 | printc(RED, "node could not be found. You need to install node to build material-shell. See https://nodejs.org/en/") |
| 74 | exit(1) |
| 75 | |
| 76 | # if which("gnome-shell") is None: |
| 77 | # printc(RED, "gnome-shell could not be found. Are you sure you are running gnome-shell?") |
| 78 | # exit(1) |
| 79 | if which("gnome-shell") is not None: |
| 80 | output = check_output(['gnome-shell', '--version']).decode('utf-8') |
| 81 | match = re.search("\d+", output) |
| 82 | if match is None or int(match.group(0)) < 40: |
| 83 | printc(RED, "Your gnome shell version seem to be below 40 and this current version is only compatible with gnome 40 and above. Try the 3.38 branch") |
| 84 | exit(1) |
| 85 | # Create install directory |
| 86 | os.makedirs(install_directory, exist_ok=True) |
| 87 | |
| 88 | # Install dependencies |
| 89 | printc(GREEN, f"Installing dependencies...") |
| 90 | if not try_call(["npm", "install", "--silent"]): |
| 91 | printc(RED, f"Failed to install dependencies") |
| 92 | exit(1) |
| 93 | |
| 94 | # Compile the typescript code |
| 95 | printc(GREEN, f"Compiling...") |
| 96 | if not try_call(["make", "compile"]): |
| 97 | printc(RED, f"Compilation failed") |
| 98 | exit(1) |
| 99 | |
| 100 | printc(GREEN, f"Installing extension...") |
| 101 | |
| 102 | def create_link(): |
| 103 | os.symlink(os.path.realpath(dist_dir), install_path) |
| 104 | |
| 105 | # Check if material-shell is already installed |
| 106 | # Note that os.path.exists returns false if a symlink exists at the path, but it is broken. So we need to check islink too. |
| 107 | if os.path.exists(install_path) or os.path.islink(install_path): |
no test coverage detected