Skip to content

Commit

Permalink
Merge pull request #57 from heyzec/master
Browse files Browse the repository at this point in the history
 Added custom background feature as per #56
  • Loading branch information
mateosss authored Mar 15, 2021
2 parents bbeef1d + 5cc264d commit ebc9c04
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 27 additions & 1 deletion matter.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,28 @@ def prepare_source_dir():
highlight = parse_color(user_args.highlight)
foreground = parse_color(user_args.foreground)
background = parse_color(user_args.background)
image = user_args.image
fontkey = user_args.font
fontfile = user_args.fontfile
fontname = user_args.fontname
fontsize = user_args.fontsize
icons = user_args.icons

# Image checks
if image:
if not exists(image):
error(
f"{image} does not exist!")
if os.path.splitext(image)[1] not in ('.png', '.tga', '.jpg', '.jpeg'):
error(
f"Background image must be one of .png, .tga, .jpg or .jpeg formats.")
image_name = basename(image)
copyfile(image, f"{INSTALLATION_SOURCE_DIR}/{image_name}")
if background:
warning(f"Both --background and --image arguments specified. Background color {background} will be ignored.")
else:
image_name = "background.png"

# Icon checks
# Read entries from grub.cfg
with open(GRUB_CFG_PATH, "r", newline="") as f:
Expand Down Expand Up @@ -393,10 +409,14 @@ def prepare_source_dir():
"highlight": highlight,
"foreground": foreground,
"background": background,
"image_name": image_name,
"fontname": fontname,
}
parsed_theme = template.format(**context)

if image:
parsed_theme = parsed_theme.replace("# desktop-image", "desktop-image")

theme_file_path = f"{INSTALLATION_SOURCE_DIR}/theme.txt"
with open(theme_file_path, "w") as f:
f.write(parsed_theme)
Expand Down Expand Up @@ -521,7 +541,7 @@ def do_install():
do_set_icons()
install_hookcheck()
update_grub_cfg()
info(f"{THEME_NAME} succesfully installed")
info(f"{THEME_NAME} successfully installed")


def do_uninstall():
Expand Down Expand Up @@ -713,6 +733,12 @@ def parse_args():
help=f"solid background color",
default=THEME_DEFAULT_BACKGROUND,
)
parser.add_argument(
"--image",
"-im",
type=str,
help=f"image file to use as background",
)
parser.add_argument(
"--iconcolor",
"-ic",
Expand Down
2 changes: 1 addition & 1 deletion theme.txt.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Global Property
title-text: ""
# desktop-image: "background.png"
# desktop-image: "{image_name}"
desktop-color: "{background}"
terminal-font: "default" # a random name to let the default font for the console
terminal-box: "terminal_box_*.png"
Expand Down

0 comments on commit ebc9c04

Please sign in to comment.