Advertisement
renix1

env i3

Sep 13th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.23 KB | None | 0 0
  1. #!/usr/bin/python2
  2. """
  3.     This script install dependencies to make polybar and another packages
  4.     that are essential
  5. """
  6. import os
  7. import subprocess
  8.  
  9.  
  10. C_PATH = os.path.join(os.environ.get('HOME'), '.config')
  11.  
  12.  
  13. class ConfigEnvironment(object):
  14.     def __init__(self):
  15.         self._fn = 'config'
  16.         self._i3 = os.path.join(C_PATH, 'i3')
  17.         self._url = "https://slexy.org/raw/s2WPP7dZps?token=df3078431c32b4785d7c60f7a1edc27edfc8033fd49d8ea5c90e365d660b70c8&ts=1536847473"
  18.         os.chdir(self._i3)
  19.         self.write()
  20.  
  21.     def write(self):
  22.         """
  23.         Write the config file on i3 path
  24.             self.write() -> None
  25.         """
  26.         print('Config environment wrote')
  27.         os.system("wget \"{}\" -O {} -q".format(self._url, self._fn))
  28.  
  29.  
  30. class LaunchFile(object):
  31.     def __init__(self):
  32.         self._fn = 'launch.sh'
  33.         self._polybar = os.path.join(C_PATH, 'polybar')
  34.         self._url = "https://paste.fedoraproject.org/paste/tySdJNWuShuDJWjs8gMLnQ/raw"
  35.         os.chdir(self._polybar)
  36.         self.write()
  37.  
  38.     def write(self):
  39.         """
  40.         Write the launch.sh file on polybar path
  41.             self.write() -> None
  42.         """
  43.         print('Launch to polybar config wrote')
  44.         os.system("wget \"{}\" -O {} -q".format(self._url, self._fn))
  45.  
  46.  
  47. class PolybarConfig(object):
  48.     def __init__(self):
  49.         self._fn = 'config'
  50.         self._polybar = os.path.join(C_PATH, 'polybar')
  51.         self._url = "https://slexy.org/raw/s21drNCMVV?token=5bc42f5b73574be1c786a8cee6cd1208d2955886153f76a9d47d91289e130e45&ts=1536847438"
  52.         os.chdir(self._polybar)
  53.         self.write()
  54.  
  55.     def write(self):
  56.         """
  57.         Write the confi file on polybar path
  58.             self.write() -> None
  59.         """
  60.         print('Polybar config wrote')
  61.         os.system("wget \"{}\" -O {} -q".format(self._url, self._fn))
  62.  
  63.  
  64. class SpotifyFile(object):
  65.     def __init__(self):
  66.         self._fn = 'spotify.sh'
  67.         self._polybar = os.path.join(C_PATH, 'polybar')
  68.         self._url = "https://slexy.org/raw/s2106qJfcX?token=50756853c117e119dddabee9aa63f1933830e09290cad8b5f9928316823f057d&ts=1536847556"
  69.         os.chdir(self._polybar)
  70.         self.write()
  71.  
  72.     def write(self):
  73.         """
  74.         Write the confi file on polybar path
  75.             self.write() -> None
  76.         """
  77.         print('Spotify wrote')
  78.         os.system("wget \"{}\" -O {} -q".format(self._url, self._fn))
  79.  
  80.  
  81. class Packages(object):
  82.     def __init__(self):
  83.         self._fn = 'principal-packages'
  84.         if not self._check_principal_packages():
  85.             print('Installing packages...')
  86.             self.install_principal_packages()
  87.  
  88.     def _check_principal_packages(self):
  89.         """
  90.         Check if principal packages are installed
  91.             self._check_principal_packages() -> Boolean value
  92.         """
  93.         with open('principal-packages', 'r') as f:
  94.             packages = f.readlines()
  95.             for package in packages:
  96.                 try:
  97.                     r = subprocess.check_output('dpkg -l | grep {}'.format(package.strip()), shell=True)
  98.                     return True
  99.                 except subprocess.CalledProcessError:
  100.                     return False
  101.  
  102.     def install_principal_packages(self):
  103.         """
  104.         Install packages :p
  105.             self.install_principal_packages() -> None
  106.         """
  107.         with open('principal-packages', 'r') as f:
  108.             packages = f.readlines()
  109.             for package in packages:
  110.                 os.system('apt install -y {}'.format(package))
  111.  
  112.  
  113. if __name__ == '__main__':
  114.     if os.getuid() != 1000:
  115.         packages = Packages()
  116.         PolybarConfig()
  117.         SpotifyFile()
  118.         LaunchFile()
  119.         ConfigEnvironment()
  120.     else:
  121.         print("Run as sudo user")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement