Dear friends,
Sorry, this is OT but I thought that some of you might have suggestions.
I want to have an on-screen indicator in the form of a icon or something that is blinking red if vpn is disconnected and steady green if vpn is up. Could also be extended to other features but right now let us go with this.
The reason I need this is because the Cisco icon (that I need for VPN because of required third-party 2FA) is very tiny and almost impossible to see. It is time-consuming and distracting to constantly have to hover over the icon to see whether it says Connected and Disconnected.
So, I am thinking of a small script that will check every second (say) if VPN is on or off and then display accordingly. The script part, I think I can write on my own. It is what th script will do/call that i am having trouble with. So any suggestions as to what I could do.
Now, I am aware that I can perhaps get something like conky to be set up for this, but I was hoping to have something far simpler. But I do not quite know how to do the simple display part.
My apologies again that this has nothing to do with Fedora, but I come as a proud and happy user of its 31 editions.
Many thanks and best wishes, Ranjan
On 2020-04-16 21:41, Ranjan Maitra wrote:
Dear friends,
Sorry, this is OT but I thought that some of you might have suggestions.
I want to have an on-screen indicator in the form of a icon or something that is blinking red if vpn is disconnected and steady green if vpn is up. Could also be extended to other features but right now let us go with this.
The reason I need this is because the Cisco icon (that I need for VPN because of required third-party 2FA) is very tiny and almost impossible to see. It is time-consuming and distracting to constantly have to hover over the icon to see whether it says Connected and Disconnected.
So, I am thinking of a small script that will check every second (say) if VPN is on or off and then display accordingly. The script part, I think I can write on my own. It is what th script will do/call that i am having trouble with. So any suggestions as to what I could do.
Now, I am aware that I can perhaps get something like conky to be set up for this, but I was hoping to have something far simpler. But I do not quite know how to do the simple display part.
My apologies again that this has nothing to do with Fedora, but I come as a proud and happy user of its 31 editions.
Many thanks and best wishes,
US-East is a OpenVPN connection of mine.
When the VPN is disconnected
[egreshko@meimei ~]$ nmcli connection show --active | grep US-East | echo $? 1
When the VPN is connected
[egreshko@meimei ~]$ nmcli connection show --active | grep US-East | echo $? 0
Is that the sort of thing you're looking for?
On Thu, 16 Apr 2020 21:54:37 +0800 Ed Greshko ed.greshko@greshko.com wrote:
On 2020-04-16 21:41, Ranjan Maitra wrote:
Dear friends,
Sorry, this is OT but I thought that some of you might have suggestions.
I want to have an on-screen indicator in the form of a icon or something that is blinking red if vpn is disconnected and steady green if vpn is up. Could also be extended to other features but right now let us go with this.
The reason I need this is because the Cisco icon (that I need for VPN because of required third-party 2FA) is very tiny and almost impossible to see. It is time-consuming and distracting to constantly have to hover over the icon to see whether it says Connected and Disconnected.
So, I am thinking of a small script that will check every second (say) if VPN is on or off and then display accordingly. The script part, I think I can write on my own. It is what th script will do/call that i am having trouble with. So any suggestions as to what I could do.
Now, I am aware that I can perhaps get something like conky to be set up for this, but I was hoping to have something far simpler. But I do not quite know how to do the simple display part.
My apologies again that this has nothing to do with Fedora, but I come as a proud and happy user of its 31 editions.
Many thanks and best wishes,
US-East is a OpenVPN connection of mine.
When the VPN is disconnected
[egreshko@meimei ~]$ nmcli connection show --active | grep US-East | echo $? 1
When the VPN is connected
[egreshko@meimei ~]$ nmcli connection show --active | grep US-East | echo $? 0
Is that the sort of thing you're looking for?
Thanks, yours is the script part. I am looking to feed this into an indicator which will blink red when 1 (in your case) and be steady green when 0 (in your example).
Many thanks again for any suggestions, Ranjan
On Thu, 16 Apr 2020 21:54:37 +0800 Ed Greshko <ed.greshko(a)greshko.com> wrote:
Thanks, yours is the script part. I am looking to feed this into an indicator which will blink red when 1 (in your case) and be steady green when 0 (in your example).
In Xfce I change a panel icon depending on a condition with the script below. I created an icon for my script and then I created the alternate version by hand and the script swaps them. this updates right away. Not flashing but maybe you can use an animated gif for icons, not sure...
#!/bin/sh
test=`grep -l 111.72.252.91 /etc/hosts` if [ "$test" == "/etc/hosts" ];then # Ad blocking seems to be on right now: rm /home/doug/Desktop/Adblock\ On.desktop cp -a /home/doug/bin/Adblock\ Off.desktop /home/doug/Desktop echo -n "" > /etc/hosts cp /etc/hosts.normal /etc/hosts else # Ad blocking seems to be off right now: rm /home/doug/Desktop/Adblock\ Off.desktop cp -a /home/doug/bin/Adblock\ On.desktop /home/doug/Desktop echo -n "" > /etc/hosts cp /etc/hosts.normal /etc/hosts cat /etc/hosts.adblocking >> /etc/hosts fi
On Thu, 16 Apr 2020 14:54:29 -0000 "Doug Herr" fedoraproject.org@wombatz.com wrote:
On Thu, 16 Apr 2020 21:54:37 +0800 Ed Greshko <ed.greshko(a)greshko.com> wrote:
Thanks, yours is the script part. I am looking to feed this into an indicator which will blink red when 1 (in your case) and be steady green when 0 (in your example).
In Xfce I change a panel icon depending on a condition with the script below. I created an icon for my script and then I created the alternate version by hand and the script swaps them. this updates right away. Not flashing but maybe you can use an animated gif for icons, not sure...
#!/bin/sh
test=`grep -l 111.72.252.91 /etc/hosts` if [ "$test" == "/etc/hosts" ];then # Ad blocking seems to be on right now: rm /home/doug/Desktop/Adblock\ On.desktop cp -a /home/doug/bin/Adblock\ Off.desktop /home/doug/Desktop echo -n "" > /etc/hosts cp /etc/hosts.normal /etc/hosts else # Ad blocking seems to be off right now: rm /home/doug/Desktop/Adblock\ Off.desktop cp -a /home/doug/bin/Adblock\ On.desktop /home/doug/Desktop echo -n "" > /etc/hosts cp /etc/hosts.normal /etc/hosts cat /etc/hosts.adblocking >> /etc/hosts fi
Thanks, is the icon called On.desktop/Off.desktop in your example?
Can I get something like this on to my screen? I use openbox window manager and no DE but that is likely irrelevant.
Ranjan
On Thu, 16 Apr 2020 14:54:29 -0000 "Doug Herr"
Thanks, is the icon called On.desktop/Off.desktop in your example?
Can I get something like this on to my screen? I use openbox window manager and no DE but that is likely irrelevant.
Actually, I see that I gave you an older version of my script. The current active one is below. It alters the panel launcher text file. It seems that Xfce desktop notices when launcher files change and will then update to show the changed icon pointer. I don't know how this would work for your setup tho...
#!/bin/sh
test=`grep -l 111.72.252.91 /etc/hosts` if [ "$test" == "/etc/hosts" ];then # Ad blocking seems to be on right now: cp /home/doug/bin/adblocking.toggle-xfce4.unlocked /home/doug/.config/xfce4/panel/launcher-20/14063898372.desktop echo -n "" > /etc/hosts cp /etc/hosts.normal /etc/hosts else # Ad blocking seems to be off right now: cp /home/doug/bin/adblocking.toggle-xfce4.locked /home/doug/.config/xfce4/panel/launcher-20/14063898372.desktop echo -n "" > /etc/hosts cp /etc/hosts.normal /etc/hosts cat /etc/hosts.adblocking >> /etc/hosts fi
On Thu, 16 Apr 2020 08:41:22 -0500 Ranjan Maitra maitra@email.com wrote:
The reason I need this is because the Cisco icon (that I need for VPN because of required third-party 2FA) is very tiny and almost impossible to see. It is time-consuming and distracting to constantly have to hover over the icon to see whether it says Connected and Disconnected.
So, I am thinking of a small script that will check every second (say) if VPN is on or off and then display accordingly. The script part, I think I can write on my own. It is what th script will do/call that i am having trouble with. So any suggestions as to what I could do.
Ed gave you the way to find out if it is connected. I found this on the web and use it as a quick timer when I want to be notified after a period of time. Start it from an xterm. It appears in whatever window you are currently working in. You should be able to trigger it with your logic. Hard to miss. Try it.
sleep 1s && date && xterm -bg red -fg yellow -g 80x40
On Thu, 16 Apr 2020 14:07:21 -0700 stan via users users@lists.fedoraproject.org wrote:
On Thu, 16 Apr 2020 08:41:22 -0500 Ranjan Maitra maitra@email.com wrote:
The reason I need this is because the Cisco icon (that I need for VPN because of required third-party 2FA) is very tiny and almost impossible to see. It is time-consuming and distracting to constantly have to hover over the icon to see whether it says Connected and Disconnected.
So, I am thinking of a small script that will check every second (say) if VPN is on or off and then display accordingly. The script part, I think I can write on my own. It is what th script will do/call that i am having trouble with. So any suggestions as to what I could do.
Ed gave you the way to find out if it is connected. I found this on the web and use it as a quick timer when I want to be notified after a period of time. Start it from an xterm. It appears in whatever window you are currently working in. You should be able to trigger it with your logic. Hard to miss. Try it.
sleep 1s && date && xterm -bg red -fg yellow -g 80x40
So, I was able to hack out a python script (I don't really know python) which does the blinking red. Blinking green is trivial after this. Here is the script (below). I am now thinking of writing the whole thing in python as a single script. Btw, how do I put this "window/indicator" into the system tray?
Thanks for the help and suggestions!
Best wishes, Ranjan
#!/usr/bin/env python
import pygame import time
WHITE = (255, 255, 255) BLUE = ( 0, 0, 255) GREEN = ( 0, 255, 0) RED = (255, 0, 0) TEXTCOLOR = ( 0, 0, 0) (width, height) = (40, 40)
running = True
background_color = WHITE
pygame.init() screen = pygame.display.set_mode((width, height)) pygame.display.set_caption("VPN-Status") screen.fill(background_color) pygame.display.update()
while running: pygame.draw.circle(screen, RED, (20, 20), 20) pygame.display.update() time.sleep(0.25) pygame.draw.circle(screen, WHITE, (20, 20), 20) pygame.display.update() time.sleep(0.25)
On Fri, 17 Apr 2020 22:51:22 -0700 Paul Allen Newell pnewell0705@gmail.com wrote:
On 4/17/20 5:53 PM, Ranjan Maitra wrote:
So, I was able to hack out a python script [...]
Ranjan:
Thank you for the script .. with modifications I have it running under python3
Paul
Thanks, Paul, and no problem. This is a place for sharing. I am just curious: what modifications did you need? Mine works with python3 (on F31).
Ranjan
On 4/18/20 5:44 AM, Ranjan Maitra wrote:
On Fri, 17 Apr 2020 22:51:22 -0700 Paul Allen Newell pnewell0705@gmail.com wrote:
On 4/17/20 5:53 PM, Ranjan Maitra wrote:
So, I was able to hack out a python script [...]
Ranjan:
Thank you for the script .. with modifications I have it running under python3
Paul
Thanks, Paul, and no problem. This is a place for sharing. I am just curious: what modifications did you need? Mine works with python3 (on F31).
Ranjan _______________________________________________
Ranjan:
I misphrased my statement about those modifications. It wasn't to get it running on python3 per se. It was to give it more flexibility.
I added the following snippet inside the loop so I can run the script (or any script using pygame) in a non-interactive fashion so the "X" for "Close Window" in the menubar of the screen works (needed to make "(width, height) = (80, 80)" to see that "X"):
[...] while running: if (event.type == pygame.QUIT): running = False [...]
and added this at the end for when we exit the loop:
[...] pygame.quit() sys.exit (0) [...]
I also added an "import os" and the following code before "pygame.init()" to allow me to position the screen
[...] (xpos, ypos) = (100, 100) os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (xpos, ypos) pygame.init() [...]
Paul
On Thu, 2020-04-16 at 08:41 -0500, Ranjan Maitra wrote:
I thought that some of you might have suggestions.
You might want to tell us what desktop you use.
On MATE there are panel apps that can be added to the toolbar, there are network monitoring ones in there. Their icon changes with status.
Old Gnome used to have them, don't know about new Gnome. I dare say KDE would have something like that, too.
On Fri, 17 Apr 2020 14:38:45 +0930 Tim via users users@lists.fedoraproject.org wrote:
On Thu, 2020-04-16 at 08:41 -0500, Ranjan Maitra wrote:
I thought that some of you might have suggestions.
You might want to tell us what desktop you use.
On MATE there are panel apps that can be added to the toolbar, there are network monitoring ones in there. Their icon changes with status.
Old Gnome used to have them, don't know about new Gnome. I dare say KDE would have something like that, too.
Sorry, I use the openbox WM and no DE. I have a system tray which I modified (minorly) an old version of peksystray and called it aNu because the original authors would not respond to my e-mail with my edits: https://github.com/maitra/aNu. I don't believe that the exact system tray is important but I have been using mine for around 10 years.
Ranjan