diff --git a/examples/album.sh b/examples/album.sh new file mode 100755 index 0000000..01de70e --- /dev/null +++ b/examples/album.sh @@ -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" diff --git a/examples/calendar.sh b/examples/calendar.sh new file mode 100755 index 0000000..3816499 --- /dev/null +++ b/examples/calendar.sh @@ -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 diff --git a/examples/failedservice.sh b/examples/failedservice.sh new file mode 100755 index 0000000..1eb275d --- /dev/null +++ b/examples/failedservice.sh @@ -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 + + diff --git a/examples/lastupgraded.sh b/examples/lastupgraded.sh new file mode 100755 index 0000000..c4ece6e --- /dev/null +++ b/examples/lastupgraded.sh @@ -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 + diff --git a/examples/neofetch.sh b/examples/neofetch.sh new file mode 100755 index 0000000..012de1c --- /dev/null +++ b/examples/neofetch.sh @@ -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 diff --git a/examples/termout.css b/examples/termout.css new file mode 100644 index 0000000..82b67b3 --- /dev/null +++ b/examples/termout.css @@ -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); */ +} diff --git a/examples/termout.sh b/examples/termout.sh new file mode 100755 index 0000000..fb01c5a --- /dev/null +++ b/examples/termout.sh @@ -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 +$title + +$cmd +DOC + +# echo -e " " + diff --git a/examples/timer.sh b/examples/timer.sh new file mode 100755 index 0000000..0cb8898 --- /dev/null +++ b/examples/timer.sh @@ -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 + diff --git a/nwg_wrapper/main.py b/nwg_wrapper/main.py index ab6e300..495fa1d 100644 --- a/nwg_wrapper/main.py +++ b/nwg_wrapper/main.py @@ -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() @@ -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", @@ -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() @@ -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) @@ -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 ""