Skip to content
New issue

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

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

Already on GitHub? # to your account

Add sig refresh #10

Merged
merged 6 commits into from
Jan 7, 2022
Merged
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
4 changes: 4 additions & 0 deletions examples/album.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
#simplay place the album in a fixed place and trigger reload of this script(using signal).

echo -e "#img path=$HOME/.cache/cover.png width=280 height=280"
7 changes: 7 additions & 0 deletions examples/calendar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

title="Today:"
color="#8EA6D6"
fontsize="12pt"
cmd="$(khal --color calendar 2>/dev/null)"
source ~/.config/nwg-wrapper/termout.sh
11 changes: 11 additions & 0 deletions examples/failedservice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
#!/usr/bin/env bash

title="Failed Systemd Unit:"
color="#c88fae"
cmd="$(systemctl --failed)"
textfont="Fixedsys Excelsior MonoL"
# fontsize="6pt"
source ~/.config/nwg-wrapper/termout.sh


10 changes: 10 additions & 0 deletions examples/lastupgraded.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

title="Last Upgrade:"
color="#a1d4c7"
pattern="$(tail -n1 /var/log/pacman.log | grep -iEo "([0-9]{4}-[0-9]{2}-[0-9]{2})").+(upgraded|installed)"
cmd=$(grep -aiE "$pattern" /var/log/pacman.log|cut -d' ' -f4|sort -u)
textfont="Fixedsys Excelsior MonoL"
# fontsize="6pt"
source ~/.config/nwg-wrapper/termout.sh

11 changes: 11 additions & 0 deletions examples/neofetch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash


#!/usr/bin/env bash

title="System:"
color="#c88fae"
textfont="Fixedsys Excelsior MonoL"
# fontsize="11pt"
cmd="$(neofetch --disable wm uptime term)"
source ~/.config/nwg-wrapper/termout.sh
22 changes: 22 additions & 0 deletions examples/termout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
window {
background-color: rgba (0, 0, 0, 0.0);
}

#box-outer {
/* Define attributes of the box surrounding icons here */
background-color: rgba (255, 255, 255, 0.0)
}

#box-inner {
/* font-family: "Fixedsys Excelsior MonoLF"; */
/* background-color: rgba (23, 53, 63, 0.75); */
/* color: #D6E1A5; */
padding: 0 20px 0 20px;
background-color: rgba (61,76,95, 0.80);
border-radius: 16px;
padding: 2em 4em;
margin: 0px 9px 9px 0px;
box-shadow: 0px 3px 5px black
/* box-shadow: 0px 8px 38px 8px rgba(0, 0, 0, 0.3); */
/* box-shadow: 0 19px 38px rgba(0, 0, 0, 0.3), 0 15px 12px rgba(0, 0, 0, 0.22); */
}
20 changes: 20 additions & 0 deletions examples/termout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

title=${title:-"Output"}
cmd=${cmd:-"I am empty"}
color=${color:-"#C88FAF"}
titlefont=${titlefont:-"SF Pro Display"}
textfont=${textfont:-"SF Mono"}
fontsize=${fontsize:-"10pt"}
# cmd
# color
#ansifilter the cmd output to pango markup.
cmd=$(ansifilter -c -M -F "$textfont" -s $fontsize -m ~/.config/nwg-wrapper/ansicolor.map --art-tundra <<< "$cmd"|sed "s/fgcolor=\"#000000\" bgcolor=\"#000000\"/bgcolor=\"#FFFFFF20\" fgcolor=\"$color\"/g")
cat - << DOC
<span foreground="$color" font_family="$titlefont" size="xx-large">$title</span>

<span foreground="$color" font_family="$textfont" >$cmd</span>
DOC

# echo -e " "

9 changes: 9 additions & 0 deletions examples/timer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

title="Systemd Timers:"
color="#8cc7d6"
cmd="$(systemctl --user list-timers|head -n -1)"
textfont="Fixedsys Excelsior MonoL"
# fontsize="11pt"
source ~/.config/nwg-wrapper/termout.sh

19 changes: 16 additions & 3 deletions nwg_wrapper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def signal_handler(sig, frame):
print("Terminated with a custom signal ({})".format(sig))
Gtk.main_quit()
elif sig == args.sig_layer:
layer = 3 if layer == args.layer else args.layer
layer = 2 if layer == 1 else 1
GtkLayerShell.set_layer(window, layer)
elif sig == args.sig_refresh:
update_label_from_script(script_path, v_box, args.justify)
elif sig == args.sig_visibility:
if window.is_visible():
window.hide()
Expand Down Expand Up @@ -213,6 +215,11 @@ def main():
type=int,
default=2,
help="custom Signal number to Quit the wrapper instance; default: 2")
parser.add_argument("-sr",
"--sig_refresh",
type=int,
default="99",
help="custom Signal number to refresh the script; default: 8")

parser.add_argument("-r",
"--refresh",
Expand Down Expand Up @@ -255,6 +262,7 @@ def main():
GtkLayerShell.set_monitor(window, monitor)
except KeyError:
print("No such output: {}".format(args.output))
return

screen = Gdk.Screen.get_default()
provider = Gtk.CssProvider()
Expand All @@ -273,8 +281,11 @@ def main():
else:
GtkLayerShell.set_anchor(window, GtkLayerShell.Edge.RIGHT, True)

GtkLayerShell.set_anchor(window, GtkLayerShell.Edge.TOP, True)
GtkLayerShell.set_anchor(window, GtkLayerShell.Edge.BOTTOM, True)
if args.alignment == "start" or args.alignment == "end":
if args.alignment == "start":
GtkLayerShell.set_anchor(window, GtkLayerShell.Edge.TOP, True)
else:
GtkLayerShell.set_anchor(window, GtkLayerShell.Edge.BOTTOM, True)

GtkLayerShell.set_margin(window, GtkLayerShell.Edge.TOP, args.margin_top)
GtkLayerShell.set_margin(window, GtkLayerShell.Edge.BOTTOM, args.margin_bottom)
Expand All @@ -294,10 +305,12 @@ def main():
else:
outer_box.pack_start(inner_box, True, False, 0)

global v_box
v_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
inner_box.pack_start(v_box, False, False, 0)

# Get data
global script_path
script_path = os.path.join(config_dir, args.script) if args.script else ""
text_path = os.path.join(config_dir, args.text) if args.text else ""

Expand Down