{"id":2848,"date":"2010-04-30T15:02:42","date_gmt":"2010-04-30T15:02:42","guid":{"rendered":"http:\/\/www.notmart.org\/index.php\/Software\/Script_your_netbook"},"modified":"2010-04-30T15:02:42","modified_gmt":"2010-04-30T15:02:42","slug":"script_your_netbook","status":"publish","type":"post","link":"https:\/\/notmart.org\/blog\/2010\/04\/script_your_netbook\/","title":{"rendered":"Script your netbook"},"content":{"rendered":"<p>This post is of the boring-with code type, but if you are a distribution packager read till the end, it&#8217;s important \ud83d\ude42<\/p>\n<p>As said by Aaron some days ago, now Plasma can be controlled vith Javascript code.<\/p>\n<p>This is useful for creating the default setup, for quicly controlling the desktop look and feel, to handle updates in the configuration files and even for controlling large deployments.<\/p>\n<p>Setup scripts can also be packaged in the same format as the Javascript based plasmoids, so in the future (probably 4.6 timeframe?) will be possible to distribute and downoad setup for actvities, for instance with get hot new stuff.<\/p>\n<p>Now not only the Plasma Desktop is using it: also the netbook has full scripting support, this will make really easy for distributions to customize the default layout as needed.<\/p>\n<p>so, let&#8217;s see how it&#8217;s done:<\/p>\n<pre>\nloadTemplate(\"org.kde.plasma-netbook.defaultSal\")\nloadTemplate(\"org.kde.plasma-netbook.defaultPanel\")\nloadTemplate(\"org.kde.plasma-netbook.defaultPage\")\n<\/pre>\n<p>It loads 3 packages, one for the Search and launch activity, one for the panel and one for the newspaper. The newspaper is:<\/p>\n<pre>\nvar page = new Activity(\"newspaper\")\n\/\/not shown by default\npage.screen = -1\n\/\/properties for the wallpaper\npage.wallpaperPlugin = 'image'\npage.wallpaperMode = 'SingleImage'\n\/\/templateName comes from the desktop file of the package,\n\/\/and will be translated\npage.name = templateName\n\npage.addWidgetAt(\"news\", 0, 0)\npage.addWidgetAt(\"weather\", 1, 0)\npage.addWidgetAt(\"opendesktop\", 0, 1)\npage.addWidgetAt(\"knowledgebase\", 1, 1)\n<\/pre>\n<p>It adds the default widgets, will be possible to distribute and download different pages. The search and launch instead is the following:<\/p>\n<pre>\nvar sal = new Activity(\"sal\")\nsal.screen = 0\nsal.wallpaperPlugin = 'image'\nsal.wallpaperMode = 'SingleImage'\nsal.name = templateName\nsal.writeConfig(\"PackageManager\", \"kpackagekit\")\nsal.reloadConfig()\n<\/pre>\n<p>The PackageManager bit here is particularly important: a new feature of the Search and Launch activity for 4.5 is a new button in the toolbox, called &#8220;Add applications&#8221; (complementar to the usual &#8220;add widgets&#8221;) it will launch the gui for the package manager&#8230; now, since it&#8217;s highly distribution dependent it will have to be customized. Here uses as default &#8220;kpackagekit&#8221; this is the name of the desktop file of the application, in OpenSuse that line would become for instance sal.writeConfig(&#8220;PackageManager&#8221;, &#8220;package-manager&#8221;) and so on<\/p>\n<p>It&#8217;s a small little bit, but it&#8217;s an important piece to give it a more integrated and easy experience.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is of the boring-with code type, but if you are a distribution packager read till the end, it&#8217;s important \ud83d\ude42 As said by Aaron some days ago, now Plasma can be controlled vith Javascript code. This is useful for creating the default setup, for quicly controlling the desktop look and feel, to handle [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[60,2,10,21,55,7],"class_list":["post-2848","post","type-post","status-publish","format-standard","hentry","category-software","tag-javascript","tag-kde","tag-kde4","tag-linux","tag-netbook","tag-plasma"],"_links":{"self":[{"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/posts\/2848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/comments?post=2848"}],"version-history":[{"count":0,"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/posts\/2848\/revisions"}],"wp:attachment":[{"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/media?parent=2848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/categories?post=2848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notmart.org\/blog\/wp-json\/wp\/v2\/tags?post=2848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}