Comments (6)
The script fails when using Linux mint. The line:
output = str(subprocess.check_output("cat /etc/*-release", shell=True).decode("utf-8"))
fails because it encounters a folder with the -release suffix.
Hi there, thanks for letting me know, I'll look into it
from dedsec-grub2-theme.
I tried it again in another PC and thats the error:
I just deleted the folder upstream-release using:
cd /etc/
sudo rm -d -r upstream-release/
I'm using Linux Mint 20.2 Cinnamon.
from dedsec-grub2-theme.
Hey @Eduardo-RFarias yeah it looks like the directory is causing the issue. Also I don't think its safe to delete those, it might cause some issue during the full system update.
I modified the install script a little bit, can you test this out and lemme know if it works fine?
#!/usr/bin/env python3
import subprocess
import os
import shutil
import re
def check_root():
id = int(subprocess.check_output("id -u", shell=True).decode("utf-8"))
if id != 0:
print("(!) Run the script with 'sudo' privileges or as root user !!\n")
exit()
def check_distro():
cwd_cont = os.listdir("/etc")
release_file_path = ""
for i in cwd_cont:
if i.endswith("-release") and os.path.isfile(f"/etc/{i}"):
release_file_path = f"/etc/{i}"
break
if not release_file_path:
raise Exception("Release file not found")
output = str(subprocess.check_output(release_file_path, shell=True).decode("utf-8"))
id = re.search(r"(\w*_ID=\w*)|(\w*ID=\w*)", output).group(0)
distro = id.split("=")[-1].lower().strip()
return distro
def change_grub_theme(grub_theme_path):
distro = check_distro()
with open("/etc/default/grub", "r") as grub_file:
data = grub_file.readlines()
flag = False
for i, line in enumerate(data):
if (distro in ["fedora","redhat"]) and (line.startswith("GRUB_TERMINAL_OUTPUT")):
data.pop(i)
data.insert(i, f'#{line}\n')
elif line.startswith("GRUB_THEME"):
flag = True
data.pop(i)
data.insert(i, f'GRUB_THEME="{grub_theme_path}"\n')
if not flag:
data.append(f'GRUB_THEME="{grub_theme_path}"\n')
with open("/etc/default/grub", "w") as grub_file:
grub_file.writelines(data)
def prompt(choices):
options = list(choices)
while True:
print(f"(#) Choose an option [{options[0]}-{options[-1]}] : ", end="")
choice = input().upper()
if choice not in options:
print(f"\nSelect one of the available options !!\n")
continue
return choice
def main():
print(
r"""
___ _ ___ ___ ___ _ _ ___ _ _
| \ ___ __| / __| ___ __ / __| _ \ | | | _ )___| |_| |_ ___ _ __ ___
| |) / -_) _` \__ \/ -_) _| | (_ | / |_| | _ \___| _| ' \/ -_) ' \/ -_)
|___/\___\__,_|___/\___\__| \___|_|_\\___/|___/ \__|_||_\___|_|_|_\___|
Written by Vandal (vandalsoul)
Github: https://github.com/vandalsoul/dedsec-grub2-theme/
"""
)
print("\n( DEDSEC GRUB-THEME INSTALLER )\n")
check_root()
THEME = "dedsec/"
if os.path.exists("/boot/grub/"):
GRUB_THEMES_DIR = "/boot/grub/themes/"
GRUB_UPDATE_CMD = "grub-mkconfig -o /boot/grub/grub.cfg"
if not os.path.exists(GRUB_THEMES_DIR):
os.mkdir(GRUB_THEMES_DIR)
elif os.path.exists("/boot/grub2/"):
GRUB_THEMES_DIR = "/boot/grub2/themes/"
GRUB_UPDATE_CMD = "grub2-mkconfig -o /boot/grub2/grub.cfg"
if not os.path.exists(GRUB_THEMES_DIR):
os.mkdir(GRUB_THEMES_DIR)
else:
print("\n(!) Couldn't find the GRUB directory. Exiting the script ...")
exit()
styles = {
"A": "Compact",
"B": "Hype",
"C": "Legion",
"D": "Unite",
"E": "Wrench",
"F": "Brainwash",
"G": "Firewall",
"H": "LoveTrap",
"I": "RedSkull",
"J": "Spam",
"K": "Spyware",
"L": "Strike",
"M": "WannaCry",
"N": "Tremor",
"O": "Stalker",
"P": "Mashup",
"Q": "Fuckery",
"R": "Reaper",
}
print("(#) Choose you Theme-Style :\n")
style_sheet_menu = f"""
(A) Compact theme (H) LoveTrap theme (O) Stalker theme
(B) Hype theme (I) RedSkull theme (P) Mashup theme
(C) Legion theme (J) Spam theme (Q) Fuckery theme
(D) Unite theme (K) Spyware theme (R) Reaper theme
(E) Wrench theme (L) Strike theme
(F) Brainwash theme (M) WannaCry theme
(G) Firewall theme (N) Tremor theme
"""
print(style_sheet_menu)
choice = prompt(styles.keys())
THEME_DIR = f"{GRUB_THEMES_DIR}{THEME}"
if os.path.exists(THEME_DIR):
print("\n")
ask = input("(?) Another version of this theme is already installed,\n Do you wish to remove it and add the new one (y/n)? [default = n] : ")
if ask.lower() != "y":
print("\n(!) No changes were made. Exiting the script ...\n")
exit()
else:
shutil.rmtree(THEME_DIR)
print("\n($) Removed the previous version ...")
print("\n($) Copying the theme directory ...")
shutil.copytree(THEME, THEME_DIR)
ICON_THEME = "color"
BACKGROUND_PATH = f"assets/backgrounds/{styles.get(choice).lower()}.png"
ICONS_PATH = f"assets/icons/{ICON_THEME}/"
shutil.copy(BACKGROUND_PATH, f"{THEME_DIR}")
shutil.copytree(ICONS_PATH, f"{THEME_DIR}/{ICON_THEME}")
os.rename(f"{THEME_DIR}{styles.get(choice).lower()}.png", f"{THEME_DIR}background.png")
os.rename(f"{THEME_DIR}{ICON_THEME}/", f"{THEME_DIR}icons/")
print("\n($) Editing the GRUB file ...")
THEME_PATH = f"{THEME_DIR}theme.txt"
change_grub_theme(THEME_PATH)
print("\n($) Updating GRUB ...\n")
subprocess.run(GRUB_UPDATE_CMD, shell=True)
print("\n($) DedSec GRUB theme was successfully installed !!\n")
exit()
if __name__ == "__main__":
try:
main()
except Exception as e:
print("\n(!) An unexpected error occured while running the script. Installation was unsuccessful ...\n")
print(f"(!) ERROR: {e}")
exit()
from dedsec-grub2-theme.
@vandalsoul Like this works for me, just changed line 26 from your previous comment.
OS=LinuxMint20.3 Una
Kernel=5.15.14-051514-generic
#!/usr/bin/env python3
import subprocess
import os
import shutil
import re
def check_root():
id = int(subprocess.check_output("id -u", shell=True).decode("utf-8"))
if id != 0:
print("(!) Run the script with 'sudo' privileges or as root user !!\n")
exit()
def check_distro():
cwd_cont = os.listdir("/etc")
release_file_path = ""
for i in cwd_cont:
if i.endswith("-release") and os.path.isfile(f"/etc/{i}"):
release_file_path = f"/etc/{i}"
break
if not release_file_path:
raise Exception("Release file not found")
# output = str(subprocess.check_output('echo '+ release_file_path, shell=True).decode("utf-8"))
output = open(release_file_path, 'r').read()
id = re.search(r"(\w*_ID=\w*)|(\w*ID=\w*)", output).group(0)
distro = id.split("=")[-1].lower().strip()
return distro
def change_grub_theme(grub_theme_path):
distro = check_distro()
with open("/etc/default/grub", "r") as grub_file:
data = grub_file.readlines()
flag = False
for i, line in enumerate(data):
if (distro in ["fedora","redhat"]) and (line.startswith("GRUB_TERMINAL_OUTPUT")):
data.pop(i)
data.insert(i, f'#{line}\n')
elif line.startswith("GRUB_THEME"):
flag = True
data.pop(i)
data.insert(i, f'GRUB_THEME="{grub_theme_path}"\n')
if not flag:
data.append(f'GRUB_THEME="{grub_theme_path}"\n')
with open("/etc/default/grub", "w") as grub_file:
grub_file.writelines(data)
def prompt(choices):
options = list(choices)
while True:
print(f"(#) Choose an option [{options[0]}-{options[-1]}] : ", end="")
choice = input().upper()
if choice not in options:
print(f"\nSelect one of the available options !!\n")
continue
return choice
def main():
print(
r"""
___ _ ___ ___ ___ _ _ ___ _ _
| \ ___ __| / __| ___ __ / __| _ \ | | | _ )___| |_| |_ ___ _ __ ___
| |) / -_) _` \__ \/ -_) _| | (_ | / |_| | _ \___| _| ' \/ -_) ' \/ -_)
|___/\___\__,_|___/\___\__| \___|_|_\\___/|___/ \__|_||_\___|_|_|_\___|
Written by Vandal (vandalsoul)
Github: https://github.com/vandalsoul/dedsec-grub2-theme/
"""
)
print("\n( DEDSEC GRUB-THEME INSTALLER )\n")
check_root()
THEME = "dedsec/"
if os.path.exists("/boot/grub/"):
GRUB_THEMES_DIR = "/boot/grub/themes/"
GRUB_UPDATE_CMD = "grub-mkconfig -o /boot/grub/grub.cfg"
if not os.path.exists(GRUB_THEMES_DIR):
os.mkdir(GRUB_THEMES_DIR)
elif os.path.exists("/boot/grub2/"):
GRUB_THEMES_DIR = "/boot/grub2/themes/"
GRUB_UPDATE_CMD = "grub2-mkconfig -o /boot/grub2/grub.cfg"
if not os.path.exists(GRUB_THEMES_DIR):
os.mkdir(GRUB_THEMES_DIR)
else:
print("\n(!) Couldn't find the GRUB directory. Exiting the script ...")
exit()
styles = {
"A": "Compact",
"B": "Hype",
"C": "Legion",
"D": "Unite",
"E": "Wrench",
"F": "Brainwash",
"G": "Firewall",
"H": "LoveTrap",
"I": "RedSkull",
"J": "Spam",
"K": "Spyware",
"L": "Strike",
"M": "WannaCry",
"N": "Tremor",
"O": "Stalker",
"P": "Mashup",
"Q": "Fuckery",
"R": "Reaper",
}
print("(#) Choose you Theme-Style :\n")
style_sheet_menu = f"""
(A) Compact theme (H) LoveTrap theme (O) Stalker theme
(B) Hype theme (I) RedSkull theme (P) Mashup theme
(C) Legion theme (J) Spam theme (Q) Fuckery theme
(D) Unite theme (K) Spyware theme (R) Reaper theme
(E) Wrench theme (L) Strike theme
(F) Brainwash theme (M) WannaCry theme
(G) Firewall theme (N) Tremor theme
"""
print(style_sheet_menu)
choice = prompt(styles.keys())
THEME_DIR = f"{GRUB_THEMES_DIR}{THEME}"
if os.path.exists(THEME_DIR):
print("\n")
ask = input("(?) Another version of this theme is already installed,\n Do you wish to remove it and add the new one (y/n)? [default = n] : ")
if ask.lower() != "y":
print("\n(!) No changes were made. Exiting the script ...\n")
exit()
else:
shutil.rmtree(THEME_DIR)
print("\n($) Removed the previous version ...")
print("\n($) Copying the theme directory ...")
shutil.copytree(THEME, THEME_DIR)
ICON_THEME = "color"
BACKGROUND_PATH = f"assets/backgrounds/{styles.get(choice).lower()}.png"
ICONS_PATH = f"assets/icons/{ICON_THEME}/"
shutil.copy(BACKGROUND_PATH, f"{THEME_DIR}")
shutil.copytree(ICONS_PATH, f"{THEME_DIR}/{ICON_THEME}")
os.rename(f"{THEME_DIR}{styles.get(choice).lower()}.png", f"{THEME_DIR}background.png")
os.rename(f"{THEME_DIR}{ICON_THEME}/", f"{THEME_DIR}icons/")
print("\n($) Editing the GRUB file ...")
THEME_PATH = f"{THEME_DIR}theme.txt"
change_grub_theme(THEME_PATH)
print("\n($) Updating GRUB ...\n")
subprocess.run(GRUB_UPDATE_CMD, shell=True)
print("\n($) DedSec GRUB theme was successfully installed !!\n")
exit()
if __name__ == "__main__":
try:
main()
except Exception as e:
print("\n(!) An unexpected error occured while running the script. Installation was unsuccessful ...\n")
print(f"(!) ERROR: {e}")
exit()
from dedsec-grub2-theme.
@Migueacalle98
Lol thanks, IDK how I missed that !!
from dedsec-grub2-theme.
Main install script has been updated, thanks guys
from dedsec-grub2-theme.
Related Issues (13)
- Pling link not working HOT 1
- How to change theme icons HOT 1
- the grub boot didn't change HOT 1
- [RELEASED] DEDSEC Update 4.0 HOT 2
- NO-CHANGE HOT 2
- Command lsb_released -i issue HOT 2
- How can i add icon of other os HOT 1
- Kali Linux boot animation not working HOT 1
- NixOS w/o a flake?? HOT 1
- Old version still around? HOT 1
- Yes, yes, YESS! HOT 3
- [SOLVED] Installation script failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dedsec-grub2-theme.