Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added WAYBAR_HIDDEN env var used to hide the waybar #210

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions images/base-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ COPY --chmod=777 scripts/init-gamescope.sh /etc/cont-init.d/init-gamescope.sh
COPY --chmod=777 scripts/launch-comp.sh /opt/gow/launch-comp.sh
COPY --chmod=777 scripts/startup.sh /opt/gow/startup.sh
COPY --chmod=777 scripts/wait-x11 /opt/gow/wait-x11
COPY --chmod=777 scripts/reconfig-waqybar.py /opt/gow/reconfig-waqybar.py

RUN apt-get update -y && \
apt-get install -y --no-install-recommends libsdl2-2.0-0 libncurses6 && \
Expand Down
3 changes: 3 additions & 0 deletions images/base-app/configs/waybar/config.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// -*- mode: jsonc -*-
{
// don't manualy change the following 3
"layer": "top",
"mode": "dock",
"start_hidden": false,
// Waybar at top layer
"position": "top",
// Waybar position (top|bottom|left|right)
Expand Down
2 changes: 2 additions & 0 deletions images/base-app/scripts/launch-comp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ function launcher() {
# Only copy waybar default config if it doesn't exist
mkdir -p $HOME/.config/waybar
cp -u /cfg/waybar/* $HOME/.config/waybar/
# Switch out settings based on $WAYBAR_HIDDEN
/opt/gow/reconfig-waqybar.py

# Sway needs to be overridden since we are going to change the resolution and app start
mkdir -p $HOME/.config/sway/
Expand Down
36 changes: 36 additions & 0 deletions images/base-app/scripts/reconfig-waqybar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
import os

WAYBAR_HIDDEN = os.getenv("WAYBAR_HIDDEN")
set_hidden = True if WAYBAR_HIDDEN == "true" or WAYBAR_HIDDEN == "yes" else False

data_out: str = ""
nest_count = 0

with open(f"{os.environ['HOME']}/.config/waybar/config.jsonc", "r") as config_file:
for line in config_file:
if line.find("{") != -1 or line.find("[") != -1: nest_count += 1
if line.find("}") != -1 or line.find("]") != -1: nest_count -= 1
if nest_count == 1:
if line.find("layer") != -1:
if set_hidden:
data_out += line.replace("top", "bottom")
else:
data_out += line.replace("bottom", "top")
continue
if line.find("mode") != -1:
if set_hidden:
data_out += line.replace("dock", "hide")
else:
data_out += line.replace("hide", "dock")
continue
if line.find("start_hidden") != -1:
if set_hidden:
data_out += line.replace("false", "true")
else:
data_out += line.replace("true", "false")
continue
data_out += line

with open(f"{os.environ['HOME']}/.config/waybar/config.jsonc", "w") as config_file:
config_file.write(data_out)