diff --git a/data/data.dat b/data/data.dat new file mode 100644 index 0000000..92c24bc Binary files /dev/null and b/data/data.dat differ diff --git a/dwl.sh b/dwl.sh index dc60f79..54caac7 100755 --- a/dwl.sh +++ b/dwl.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -python3 /usr/share/linuxDynamicWallpapers/main.py \ No newline at end of file +python3 /usr/share/linuxDynamicWallpapers/main.py \ No newline at end of file diff --git a/install.py b/install.py index 2009678..0f6e047 100644 --- a/install.py +++ b/install.py @@ -1,7 +1,7 @@ import os import subprocess -def checkForRoot(): +def checkForRoot(): #Checks whether root priviledges have been provided . if(subprocess.getoutput("whoami")!="root"): print("Please execute the program as root!!") print("Exiting..") @@ -9,7 +9,7 @@ def checkForRoot(): else: installPreBuildDependencies() -def installPreBuildDependencies(): +def installPreBuildDependencies(): #Installing the pre-build dependencies print("Installing dependencies.....\n\nThis may take a few moments.....") if(subprocess.getstatusoutput("pip3")[0]!=0): os.system("sudo apt install python3-pip -y") @@ -20,10 +20,10 @@ def installPreBuildDependencies(): os.system("clear") installBuildDependencies() -def installBuildDependencies(): +def installBuildDependencies(): #install the build dependencies from pyfiglet import Figlet from termcolor import colored - + banner = Figlet(font="big") print(colored(banner.renderText("Linux Dynamic Wallpapers"),color="yellow")) print("\n") @@ -32,7 +32,7 @@ def installBuildDependencies(): a = input("checkpoint 1") print(colored("Installing Build libraries. This may take some time.",color="green")) os.system("sudo apt-get install x11-xserver-utils python3-pyqt5 python3-pyqt5.qtwebengine python3-pyqt5.qtwebchannel libqt5webkit5-dev feh cron -y") - os.system("pip3 install Flask pywebview") + os.system("pip3 install Flask pywebview argparse") b = input("checkpoint 2") print(colored("Installing files. This may take a while.",color="green")) if(os.path.exists("/usr/share/linuxDynamicWallpapers")): @@ -40,25 +40,33 @@ def installBuildDependencies(): os.system("sudo mkdir -p /usr/share/linuxDynamicWallpapers") else: os.system("sudo mkdir -p /usr/share/linuxDynamicWallpapers") - #os.system("sudo cp -r ./data /usr/share/linuxDynamicWallpapers") + os.system("sudo cp -r ./data /usr/share/linuxDynamicWallpapers") os.system("sudo cp -r ./static /usr/share/linuxDynamicWallpapers") os.system("sudo cp -r ./templates /usr/share/linuxDynamicWallpapers") os.system("sudo cp -r ./images /usr/share/linuxDynamicWallpapers") os.system("sudo cp -r ./dwl.sh /usr/share/linuxDynamicWallpapers") + os.system("sudo cp -r ./setdwl.sh /usr/share/linuxDynamicWallpapers") os.system("sudo cp -r ./main.py /usr/share/linuxDynamicWallpapers") os.system("sudo chmod +x /usr/share/linuxDynamicWallpapers/dwl.sh") + os.system("sudo chmod +x /usr/share/linuxDynamicWallpapers/setdwl.sh") + os.system("sudo chmod 777 /usr/share/linuxDynamicWallpapers/data/data.dat") if(os.path.exists("/usr/bin/dwl")): os.system("sudo rm -rf /usr/bin/dwl") os.system("sudo ln -s /usr/share/linuxDynamicWallpapers/dwl.sh /usr/bin/dwl") + if(os.path.exists("/usr/bin/setdwl")): + os.system("sudo rm -rf /usr/bin/setdwl") + os.system("sudo ln -s /usr/share/linuxDynamicWallpapers/setdwl.sh /usr/bin/setdwl") else: os.system("sudo ln -s /usr/share/linuxDynamicWallpapers/dwl.sh /usr/bin/dwl") + os.system("sudo ln -s /usr/share/linuxDynamicWallpapers/setdwl.sh /usr/bin/setdwl") os.system("clear") print(colored("Finished!!",color="green")) print("\n") print(colored("Linux Dynamic Wallpapers have been installed in your system.\n\n",color="blue")) print(colored(f"To use it now, just type dwl in the terminal",color="green")) -def cleanUp(): + +def cleanUp(): #Clean up the installation files. Not executing as of now os.system("rm -rf ./data") os.system("rm -rf ./static") os.system("rm -rf ./templates") diff --git a/main.py b/main.py index 12c0a9e..27024a8 100755 --- a/main.py +++ b/main.py @@ -2,10 +2,21 @@ import datetime from flask import Flask, render_template, request, url_for import webview import os +import pickle +import argparse import multiprocessing import subprocess +""" +The program first reads for the required info stored in the ./data/data.dat binary file. +""" app = Flask(__name__) +parser = argparse.ArgumentParser() +parser.add_argument("--type",type=str,required=False) +args = parser.parse_args() +fr = open(r"/usr/share/linuxDynamicWallpapers/data/data.dat","rb") +data = pickle.load(fr) +fr.close() @app.context_processor def override_url_for(): @@ -19,35 +30,37 @@ def dated_url_for(endpoint, **values): endpoint, filename) values['q'] = int(os.stat(file_path).st_mtime) return url_for(endpoint, **values) + + def setDEWallpaper(de,style): - if style in ["bitday","firewatch","gradient"]: + if style in ["bitday","firewatch","gradient"]: #only these 3 types have .png file extension. type = ".png" else: type = ".jpg" - if de in ["/usr/share/xsessions/plasma","NEON","neon","PLASMA","Plasma","plasma","KDE","Kde","kde"]: + if de in ["/usr/share/xsessions/plasma","NEON","neon","PLASMA","Plasma","plasma","KDE","Kde","kde"]: #Set Wallpaper for Plasma DE print("Inside",de) os.system("qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'var allDesktops = desktops();print (allDesktops);for (i=0;i