From 84d06fd623a25ceb4b705d54bc05e95b6cc4cbb0 Mon Sep 17 00:00:00 2001 From: Hill Date: Sat, 25 Dec 2021 19:43:37 +0800 Subject: [PATCH 1/6] add sig_refresh --- nwg_wrapper/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nwg_wrapper/main.py b/nwg_wrapper/main.py index ab6e300..30a6507 100644 --- a/nwg_wrapper/main.py +++ b/nwg_wrapper/main.py @@ -49,6 +49,8 @@ def signal_handler(sig, frame): elif sig == args.sig_layer: layer = 3 if layer == args.layer else args.layer 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=8, + help="custom Signal number to refresh the script; default: 8") parser.add_argument("-r", "--refresh", From 6f95224102633fb708837771f5afa9b2798ff72e Mon Sep 17 00:00:00 2001 From: Hill Date: Sat, 25 Dec 2021 20:14:59 +0800 Subject: [PATCH 2/6] rough fix on var scope --- nwg_wrapper/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nwg_wrapper/main.py b/nwg_wrapper/main.py index 30a6507..7614bf5 100644 --- a/nwg_wrapper/main.py +++ b/nwg_wrapper/main.py @@ -301,10 +301,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 "" From 19a734952524b7e43a8a0e665fecbe4e1f384e53 Mon Sep 17 00:00:00 2001 From: Hill Date: Sun, 26 Dec 2021 15:49:51 +0800 Subject: [PATCH 3/6] quit when output not exists --- nwg_wrapper/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nwg_wrapper/main.py b/nwg_wrapper/main.py index 7614bf5..d72c8d4 100644 --- a/nwg_wrapper/main.py +++ b/nwg_wrapper/main.py @@ -218,7 +218,7 @@ def main(): parser.add_argument("-sr", "--sig_refresh", type=int, - default=8, + default="99", help="custom Signal number to refresh the script; default: 8") parser.add_argument("-r", @@ -262,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() @@ -313,6 +314,7 @@ def main(): if script_path: r = "refresh rate {} ms".format(args.refresh) if args.refresh else "no refresh" print("Using script: {}, {}".format(script_path, r)) + print("the script path is:", script_path) update_label_from_script(script_path, v_box, args.justify) elif text_path: print("Using text file: {}".format(text_path)) From 2ec3082957cd966dd153ba9e65d2cb6d6f0c6b52 Mon Sep 17 00:00:00 2001 From: Hill Date: Tue, 28 Dec 2021 17:17:51 +0800 Subject: [PATCH 4/6] fix anchor issue --- nwg_wrapper/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nwg_wrapper/main.py b/nwg_wrapper/main.py index d72c8d4..27d7edf 100644 --- a/nwg_wrapper/main.py +++ b/nwg_wrapper/main.py @@ -281,8 +281,14 @@ 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_anchor(window, GtkLayerShell.Edge.TOP, True) + # 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) From b0998a2b4b69eaae5cec3d80aa16e40ea77601ca Mon Sep 17 00:00:00 2001 From: Hill Date: Tue, 4 Jan 2022 16:16:56 +0800 Subject: [PATCH 5/6] add examples --- examples/album.sh | 4 ++++ examples/calendar.sh | 7 +++++++ examples/failedservice.sh | 11 +++++++++++ examples/lastupgraded.sh | 10 ++++++++++ examples/neofetch.sh | 11 +++++++++++ examples/termout.css | 22 ++++++++++++++++++++++ examples/termout.sh | 20 ++++++++++++++++++++ examples/timer.sh | 9 +++++++++ 8 files changed, 94 insertions(+) create mode 100755 examples/album.sh create mode 100755 examples/calendar.sh create mode 100755 examples/failedservice.sh create mode 100755 examples/lastupgraded.sh create mode 100755 examples/neofetch.sh create mode 100644 examples/termout.css create mode 100755 examples/termout.sh create mode 100755 examples/timer.sh 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 + From 3163234c7ec83dbc205262b449434c8431a70fc7 Mon Sep 17 00:00:00 2001 From: Hill Date: Tue, 4 Jan 2022 16:19:40 +0800 Subject: [PATCH 6/6] merge upstream update --- nwg_wrapper/main.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/nwg_wrapper/main.py b/nwg_wrapper/main.py index 27d7edf..495fa1d 100644 --- a/nwg_wrapper/main.py +++ b/nwg_wrapper/main.py @@ -47,7 +47,7 @@ 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) @@ -287,9 +287,6 @@ def main(): else: GtkLayerShell.set_anchor(window, GtkLayerShell.Edge.BOTTOM, True) - # GtkLayerShell.set_anchor(window, GtkLayerShell.Edge.TOP, True) - # 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) GtkLayerShell.set_margin(window, GtkLayerShell.Edge.LEFT, args.margin_left) @@ -320,7 +317,6 @@ def main(): if script_path: r = "refresh rate {} ms".format(args.refresh) if args.refresh else "no refresh" print("Using script: {}, {}".format(script_path, r)) - print("the script path is:", script_path) update_label_from_script(script_path, v_box, args.justify) elif text_path: print("Using text file: {}".format(text_path))