Xfce Forum

Sub domains
 

You are not logged in.

#1 2022-04-09 00:25:24

Mellowbob
Member
Registered: 2011-10-16
Posts: 286

Customized command

I have a launcher in my panel I call Google-Calendar. Pretty simple, really ... it's just a menu command with the name "Google Calendar" and the command

  google-chrome --app=https://calendar.google.com/calendar

Oh, and I grabbed an icon as well.

So, this works great and brings up my calendar with a single click.

Now, I'd like to program this so that clicking the icon a 2nd time kills off the chrome window. I'm thinking that if I put this into a little script which looks like this it should work:

      # custom launcher
      if window is present:
           remove window
      else:
           google-chrome --app=https://calendar.google.com/calendar

Suggestion as to figure out "window is present" and "remove" would be appreciated.

Offline

#2 2022-04-09 01:40:57

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: Customized command

You can use pgrep to see if its running. Try a script like this:

#!/bin/bash

pgrep -f calendar.google.com && \
	pkill -f calendar.google.com || \
	google-chrome --app=https://calendar.google.com/calendar

Basically,
Line 1 = see if there is a process running that has "calendar.google.com" in its command string, AND ( && ) if so
Line 2 = kill it, OR ( || )
Line 3 = start it


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2022-04-09 02:51:45

Mellowbob
Member
Registered: 2011-10-16
Posts: 286

Re: Customized command

Thanks so much. Works perfectly.

Not that it really matters since I'm not calling this from a terminal, but if I do I get:

bob$ my-google-cal
[1187805:1187805:0408/194309.189680:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
[1187763:1187831:0408/194309.703448:ERROR:nss_util.cc(286)] After loading Root Certs, loaded==false: NSS error code: -8018

Assuming that this is google-chrome complaining. Hmmm, quick search shows that there is a disparity between the application and the nss lib. I'm probably safe to return to the bliss generated by my ignorance.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.011 seconds, 9 queries executed - Memory usage: 535.82 KiB (Peak: 536.66 KiB) ]