{"id":2458,"date":"2017-04-27T16:28:06","date_gmt":"2017-04-27T16:28:06","guid":{"rendered":"http:\/\/cloudkul.com\/blog\/?p=2458"},"modified":"2017-06-14T11:33:06","modified_gmt":"2017-06-14T11:33:06","slug":"display-notification-login-ubuntu","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/","title":{"rendered":"To Display A Notification After Login in Ubuntu"},"content":{"rendered":"<p>The best and a very easy way to display any important information on the employee screen after login.<\/p>\n<p>We can create a script for this, in this script we can manually give the message which we want to give or we can take message from mysql database. We can also customize for how much time the screen will display the message.<\/p>\n<p>We can use notify-send for this desktop notification. With notify-send we can send desktop notifications to the user via a notification daemon from the command line. These notifications can be used to tell user about an event or display some form of information without getting in the user way.<\/p>\n<p>In this script, we are going to use pgrep command, pgrep is a command line utility. It searches for all the named processes that can be specified as extended regular expression patterns and returns their process ID.<\/p>\n<p>Let\u2019s start writing script.<\/p>\n<pre class=\"lang:default decode:true\">#!\/bin\/bash                                             #(#!) it is called shebang and (\/bin\/bash) is the path to the interpreter that is used to run the rest of the lines in the text file.\r\n\r\nSleep 10                                                #we are using sleep 10 , because some slow systems take some time to display the screen after providing password.\r\n\r\na='pgrep notify-osd'                                    #here, we are storing the process id of notify-osd in variable 'a' .\r\n\r\nnotify-send \"Message\" \"Good Morning. Have a Nice day\"   #here, we are providing title and body of the message.\r\n\r\nsleep 3                                                 #Sleep 3 is used to give some time gap.\r\n\r\nkill -19 $a                                             #kill -19 is used to pause the notify-osd process.\r\n\r\nsleep 60                                                #Here we can decide for how much time screen will display message.\r\n\r\nkill -18 $a                                             #kill -18 is used to continue the process again which we have paused using kill -19.<\/pre>\n<p>Don&#8217;t forgot to give execution permission to the file using command below.<\/p>\n<pre class=\"lang:default decode:true \">chmod +x &lt;script_name&gt;<\/pre>\n<p>And our script is ready.<\/p>\n<p>Now to run this script, after login follow the steps given below.<\/p>\n<p>switch to your home directory and then go to autostart directory.<\/p>\n<pre class=\"lang:default decode:true\">cd \r\ncd .config\/autostart\/<\/pre>\n<p>In this directory create a .desktop file like script.desktop and add execution path equals to the path to your script , there is no need to change any other things.<\/p>\n<pre class=\"lang:default decode:true\">[Desktop Entry]\r\nType=Application\r\nExec=\/home\/users\/nitin.kaushik\/finalscript.sh\r\nHidden=false\r\nNoDisplay=false\r\nX-GNOME-Autostart-enabled=true\r\nName=myscript\r\nComment=Startup Script<\/pre>\n<p>save and exit file.<\/p>\n<p>Reboot and message will be displayed after login like this.<\/p>\n<p><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/04\/Screenshot-from-2017-04-27-21-48-14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2477\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/04\/Screenshot-from-2017-04-27-21-48-14.png\" alt=\"\" width=\"1366\" height=\"768\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/cloudkul.com\/contact\/\">IN CASE OF ANY QUERY,CONTACT US<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The best and a very easy way to display any important information on the employee <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":17,"featured_media":2471,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>To Display A Notification After Login in Ubuntu - Cloudkul<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"To Display A Notification After Login in Ubuntu - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"The best and a very easy way to display any important information on the employee [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-27T16:28:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-14T11:33:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/04\/149u3MNy.png\" \/>\n\t<meta property=\"og:image:width\" content=\"848\" \/>\n\t<meta property=\"og:image:height\" content=\"422\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nitin Kaushik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/\",\"name\":\"To Display A Notification After Login in Ubuntu - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2017-04-27T16:28:06+00:00\",\"dateModified\":\"2017-06-14T11:33:06+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/99e46a85b2ad2848198f6de2c90bcbc4\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"To Display A Notification After Login in Ubuntu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/99e46a85b2ad2848198f6de2c90bcbc4\",\"name\":\"Nitin Kaushik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fdc703824bce4bae43a834dfdf641f46?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fdc703824bce4bae43a834dfdf641f46?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Nitin Kaushik\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/nitin-kaushik680\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"To Display A Notification After Login in Ubuntu - Cloudkul","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/","og_locale":"en_US","og_type":"article","og_title":"To Display A Notification After Login in Ubuntu - Cloudkul","og_description":"The best and a very easy way to display any important information on the employee [...]","og_url":"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/","og_site_name":"Cloudkul","article_published_time":"2017-04-27T16:28:06+00:00","article_modified_time":"2017-06-14T11:33:06+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/04\/149u3MNy.png","type":"image\/png"}],"author":"Nitin Kaushik","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/","url":"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/","name":"To Display A Notification After Login in Ubuntu - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2017-04-27T16:28:06+00:00","dateModified":"2017-06-14T11:33:06+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/99e46a85b2ad2848198f6de2c90bcbc4"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/display-notification-login-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"To Display A Notification After Login in Ubuntu"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/99e46a85b2ad2848198f6de2c90bcbc4","name":"Nitin Kaushik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fdc703824bce4bae43a834dfdf641f46?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdc703824bce4bae43a834dfdf641f46?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Nitin Kaushik"},"url":"https:\/\/cloudkul.com\/blog\/author\/nitin-kaushik680\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/2458"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=2458"}],"version-history":[{"count":22,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/2458\/revisions"}],"predecessor-version":[{"id":2508,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/2458\/revisions\/2508"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/2471"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=2458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=2458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=2458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}