Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import subprocess
  5.  
  6. PROGRAMS = [
  7.     "chromium",
  8.     "conky",
  9.     "feh",
  10.     "emacs",
  11.     "gvim",
  12.     "git",
  13.     "i3",
  14.     "mpv",
  15.     "zsh",
  16.     "zathura",
  17. ]
  18.  
  19. def is_tool(name):
  20.     """Check whether `name` is on PATH and marked as executable."""
  21.  
  22.     # from whichcraft import which
  23.     from shutil import which
  24.  
  25.     return which(name) is not None#
  26.  
  27. # Make sure system is updated first"
  28. print("\nsudo pacman -Syu")
  29. try:
  30.     subprocess.call("sudo pacman -Syu", shell=True)
  31. except:
  32.     quit()
  33.  
  34.  
  35. AURS = ["aurman", "yay", "trizen", "yaourt"]
  36. for i, name in enumerate(AURS):
  37.     print((i), name)
  38.  
  39. num, aur_len = -1, len(AURS)
  40. while num < 0 or num > aur_len-1:
  41.     string = input('\nEnter a valid AUR helper: ')
  42.     try:
  43.         num = int(string)
  44.     except ValueError:
  45.         print("Input must be an integer [0:",aur_len,"]")
  46.  
  47. AUR = AURS[num]
  48. if is_tool(AUR):
  49.     print("{} is already installed".format(AUR))
  50. else:
  51.     subprocess.call("pacman -S {}".format(AUR), shell=True)
  52.  
  53.  
  54. for PROGRAM in PROGRAMS:
  55.     print("\n",PROGRAM)
  56.     if is_tool(PROGRAM):
  57.         print("{} is already installed".format(PROGRAM))
  58.     else:
  59.         subprocess.call("{} -S {}".format(AUR, PROGRAM), shell=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement