From 29848001bebaada364e1ac34b72d7a880d6cb60b Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 17 May 2023 05:24:26 +0200 Subject: [PATCH] Initial commit, Notification function --- .../extension.js | 119 ++++++++++++++++++ cinnamon-dynamic-wallpaper@TobiZog/icon.png | 1 + .../icons/icon.png | Bin 0 -> 1338 bytes .../metadata.json | 11 ++ 4 files changed, 131 insertions(+) create mode 100644 cinnamon-dynamic-wallpaper@TobiZog/extension.js create mode 120000 cinnamon-dynamic-wallpaper@TobiZog/icon.png create mode 100644 cinnamon-dynamic-wallpaper@TobiZog/icons/icon.png create mode 100644 cinnamon-dynamic-wallpaper@TobiZog/metadata.json diff --git a/cinnamon-dynamic-wallpaper@TobiZog/extension.js b/cinnamon-dynamic-wallpaper@TobiZog/extension.js new file mode 100644 index 0000000..1183b28 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/extension.js @@ -0,0 +1,119 @@ +/** + * @name Cinnamon-Dynamic-Wallpaper + * @alias TobiZog + * @since 2023 + */ + + +/********** Constants **********/ + +const UUID = "cinnamon-dynamic-wallpaper@TobiZog"; +const APPNAME = "Cinnamon Dynamic Wallpaper" + + +/********** Imports **********/ + +const MessageTray = imports.ui.messageTray; +const St = imports.gi.St; +const Main = imports.ui.main; + + +/********** Global Variables **********/ + +// The extension object +let extension; + + +/********** Objects **********/ + +function CinnamonDynamicWallpaperExtension(uuid) { + this._init(uuid); +} + + +CinnamonDynamicWallpaperExtension.prototype = { + /** + * Initialization + * + * @param {string} uuid Universally Unique Identifier + */ + _init: function(uuid) { + // todo + + // Display the welcome notification on activation + this.showNotification( + APPNAME, + "Welcome to " + APPNAME + "! Open the settings and configure the extensions.", + true + ); + }, + + + /** + * Displaying a desktop notification + * + * @param {string} title The Title in the notification + * @param {string} text The text in the notification + * @param {boolean} showOpenSettings Display the "Open settings" button in the notification, defaults to false + */ + showNotification: function (title, text, showOpenSettings = false) { + let source = new MessageTray.Source(this.uuid); + + // Parameter + let params = { + icon: new St.Icon({ + icon_name: "icon", + icon_type: St.IconType.FULLCOLOR, + icon_size: source.ICON_SIZE + }) + }; + + // The notification itself + let notification = new MessageTray.Notification(source, title, text, params); + + // Display the "Open settings" button, if showOpenSettings + if (showOpenSettings) { + notification.addButton("open-settings", _("Open settings")); + + notification.connect("action-invoked", () => + Util.spawnCommandLine("xlet-settings extension " + UUID)); + } + + // Put all together + Main.messageTray.add(source); + + // Display it + source.notify(notification); + }, +} + + + +/********** Lifecycle **********/ + +/** + * Lifecycle function on initialization + * + * @param {*} extensionMeta Metadata of the extension + */ +function init(extensionMeta) { + extension = new CinnamonDynamicWallpaperExtension(extensionMeta.uuid); +} + + +/** + * Lifecycle function on enable + * + * @returns The extension object + */ +function enable() { + return extension; +} + + +/** + * Lifecycle function on disable + */ +function disable() { + // todo +} \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/icon.png b/cinnamon-dynamic-wallpaper@TobiZog/icon.png new file mode 120000 index 0000000..9db683c --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/icon.png @@ -0,0 +1 @@ +icons/icon.png \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/icons/icon.png b/cinnamon-dynamic-wallpaper@TobiZog/icons/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d9aa7a8c986e2d7616d172996be6819b092da666 GIT binary patch literal 1338 zcmW;MeKb^Q7y$71UKev`Qe4WI#F%D=kAx|gS4%zT74i2Lr8mP|9F4TbDsA+=Xu_L-h4^qIx9Mh z4gjzchXzThNSF@Ig7W_AEzMMbvZd<+K~1aUdjOCzagZoFr+nz-sw_KS>t8D3R|BPO zXs(40)7faVL8LGwa2G6%>}_|by{yU9qnc2ESY|DWuYRy%#o~+4);yl(+^w%EeOl3z zlAQcq^3k@{Gtlv}(O2FTirY&6tht~BkK38ywQFzoovDfJFG{TCQMYb+g>yCJb#G>D zJ0nWIqq9-*b-*zEw%OhX?eB|%Y2m7@kHh;1_YaL9x_rd*OCi^g)z7d``!+fK?-M?H zt0!l7+4UH-RxSf%ysF#ZBT>xqNVqDv--*PnLL8+WLr>EKkCK8+O|bjQSj0)qxUZ;5 zh?CiWp8dE^C*1qI6a+?KEdis2HojK7d4!&ua`v32K})(ph}WFI^0gMhDBA~pK_xO6 zlnB){ESdo%uvI-T1p_3)$_Z=t07A4r)#1Q=D0ZRfg|v5i`s%aSSNT*mHno(rkU>N_ zmL9)sTmHC07!TN0$PMYw{7mnTHfG3d|KktgTaF^u$B<9&Pk_KOuEu9{UTvtd#x%7r z>$BD;f|Ia$!H)h-iCO^b$T^1!^UhO?uvz^kF)x$!os{^zhAyavO7si&Kp?DFOfwnG zG%0eU#3TGoibG8X$CwnQP`3XzLUoa@0tEDzk`ppf>i>!BMFhAhm%TU17np%K+Fy5;zGlcjY*294Q6%B04VRBxcAPkvGz2AXEWhC z(&Lv~fLNd5DffJW-umfp7iR2fG=91Jqx-PKwkj>H$@1_#h-d!ljEv@up0V5f&WlLu z=(gsIY_E6|qcT(Y{Mqm^l_3?tH;?A;7o3(OzJ z<|?t3@=M<8?aX);2fE(2|8$-6;vcSUBBBbsC8`617+%-MC?V2_#1I|6o`_0rlssuH z=HhVl(gMWQoVm})xcSvl1oMT9yLlv_%gb;Xv9T{9Whi3OUGe;j67e@``r#PCIrKJvrCS`Htw z)iVpZ{^quNWvEyPm1{VVc_vqd*y$ZI&?9v6rpx+e^;1Iv$d*mpj7bP#PN)!4ZSgc* z0ynOhamKr()OwO?E(w&iMZJ}vII-5Xc)EKNRfQE{*95{h-KRxmv*TIpd#c)z17R ig!peHFx^MMF(lXrFuJaU_5DhHhCmz~8B`O9tNsHTMIJK% literal 0 HcmV?d00001 diff --git a/cinnamon-dynamic-wallpaper@TobiZog/metadata.json b/cinnamon-dynamic-wallpaper@TobiZog/metadata.json new file mode 100644 index 0000000..f406400 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/metadata.json @@ -0,0 +1,11 @@ +{ + "uuid": "cinnamon-dynamic-wallpaper@TobiZog", + "name": "Cinnamon Dynamic Wallpaper", + "description": "Cinnamon extension for dynamic desktop backgrounds based on time and location", + "version": "1.0", + "cinnamon-version": [ + "5.6" + ], + "max-instances": 1, + "url": "https://github.com/TobiZog/cinnamon-dynamic-wallpaper" +} \ No newline at end of file