• Guests may view all public nodes. However, you must be registered to post.

DEFCON Desktop Linux app (UNOFFICIAL)

iron_eagl

Member
Hey everyone!

As someone who recently switched over to Linux, but has been reading the DEFCON Warning System for over 5 years, I found that I missed the desktop app. Looking over the forums (New Apps in the works, DEFCON Desktop and Android App) I found that the then-current solution (use cron to fire off an alert when defconwarningsystem.com/current/defcon.jpg changes), while lightweight, lacked the feeling of a real desktop alert.

I've coded up a solution on GitHub over the past week, and it's almost at the point where I would call it "finished". Currently, I lack access to the images for DEFCON levels 3, 2, and 1, but the main functionality is there. If you have been looking for a desktop app for Linux, please feel free to download the script and let me know what you think. Also, if someone has access to "modern" DEFCON images 3, 2, or 1, please send me a PM.

Link: GitHub:DWS-linux
 
I run Linux on my laptop. I can download and test it.
 
Nothing malicious in the script. Copied install directory to where I wanted it and edited the script accordingly. On execution, the "NC" icon appears in my system tray, and I get the following errors:
Code:
convert: unable to open image `/home/eric/DWS/DWS-linux/defcon.jpg': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: no images defined `txt:-' @ error/convert.c/ConvertImageCommand/3210.
./DWS-linux.sh: line 55: [: ==: unary operator expected
./DWS-linux.sh: line 58: [: ==: unary operator expected
No defcon image - is this the first run? Check INSTALL_DIR
stat: cannot stat 'defcon.jpg': No such file or directory
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
./DWS-linux.sh: line 85: --no-http-keep-alive: command not found
wget error: 0
stat: cannot stat 'defcon.jpg': No such file or directory

(yad:12662): Gtk-WARNING **: Theme parsing error: gtk.css:2559:14: 'min-height' is not a valid property name

(yad:12662): Gtk-WARNING **: Theme parsing error: gtk.css:4082:12: 'min-height' is not a valid property name

(yad:12662): Gtk-WARNING **: Theme parsing error: gtk.css:4083:11: 'min-width' is not a valid property name

(yad:12662): Gtk-WARNING **: Theme parsing error: gtk.css:6915:1: '/*' in comment block

(yad:12662): Gtk-WARNING **: Theme parsing error: gtk.css:7076:1: '/*' in comment block

(yad:12662): Gtk-WARNING **: Theme parsing error: gtk.css:7091:1: '/*' in comment block

(yad:12662): Gtk-WARNING **: Theme directory  of theme oxygen has no size field

The first time I ran it I was receiving an error that "--no-netrc was not a recognized option" for wget, so I commented that out to see what would happen. Result was the "Missing URL" error listed above. Script is looking for a JPG image in the install directory that does not exist. On lines 55 and 58, do you need quotation marks around the variables?

The Gtk warnings are not runtime errors, but you should know about them for future development.

I am running Linux Mint 18.3 "Sylvia" 64-bit.
Kernel is Linux 4.4.0-141-generic x86_64.
I'm using Mate as my desktop environment

Please let me know if you need any further information or if there are changes you recommend to the script. I'm not a programmer, but I'm pretty comfortable with small scripts like this.

Thank you for developing this. I look forward to getting it working on my system.

-Riff
 
Thanks for testing it out, and posting all the error messages!

The first six lines will always occur if wget couldn't download the image - i.e. if there is not yet any image in the main directory of the script, which also happens on the first run. It seems that then there is an error with wget, so there is never any image downloaded.

I wasn't aware that --no-netrc wasn't supported universally - it's not specifically needed for the script to actually run. Given the error about line 85 and the "missing url" option, it seems that commenting out the line broke the flow of the command. In fact, I was able to reproduce that portion of the error by commenting out the --no-netrc option. Try removing that line entirely - it should be
Code:
wget --no-http-keep-alive \
 --no-cookies \
 --user-agent="DWS-linux_test" \
 --directory-prefix="$INSTALL_DIR" \
 --timestamping "https://defconwarningsystem.com/current/defcon.jpg"

I'll see what I can do about the Gtk warnings - it looks like it's internal to yad, but there might be some options I can specify.
 
That worked. I got a popup window notifying me of the DEFCON change to level 4 with the appropriate logo, and the system try icon is now displaying a blue 4. Here is the verbose error reporting, but I think it's really minor stuff with the GTK:
Code:
convert: unable to open image `/home/eric/DWS/DWS-linux/defcon.jpg': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: no images defined `txt:-' @ error/convert.c/ConvertImageCommand/3210.
./DWS-linux.sh: line 55: [: ==: unary operator expected
./DWS-linux.sh: line 58: [: ==: unary operator expected
No defcon image - is this the first run? Check INSTALL_DIR
stat: cannot stat 'defcon.jpg': No such file or directory
--2019-03-08 13:22:13--  https://defconwarningsystem.com/current/defcon.jpg
Resolving defconwarningsystem.com (defconwarningsystem.com)... 198.252.105.78
Connecting to defconwarningsystem.com (defconwarningsystem.com)|198.252.105.78|:443... 
(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:2559:14: 'min-height' is not a valid property name

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:4082:12: 'min-height' is not a valid property name

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:4083:11: 'min-width' is not a valid property name

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:6915:1: '/*' in comment block

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:7076:1: '/*' in comment block

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:7091:1: '/*' in comment block

(yad:13578): Gtk-WARNING **: Theme directory  of theme oxygen has no size field

connected.
HTTP request sent, awaiting response... 200 OK
Length: 51435 (50K) [image/jpeg]
Saving to: ‘/home/eric/DWS/DWS-linux/defcon.jpg’

defcon.jpg          100%[===================>]  50.23K  --.-KB/s    in 0.1s    

2019-03-08 13:22:13 (481 KB/s) - ‘/home/eric/DWS/DWS-linux/defcon.jpg’ saved [51435/51435]


(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:2559:14: 'min-height' is not a valid property name

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:4082:12: 'min-height' is not a valid property name

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:4083:11: 'min-width' is not a valid property name

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:6915:1: '/*' in comment block

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:7076:1: '/*' in comment block

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:7091:1: '/*' in comment block

(yad:13584): Gtk-WARNING **: Theme directory  of theme oxygen has no size field

Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

Edit: This is a nice compact script. It seems you are a follower of the KISS principle, and you believe in including notes in your code. I'm very impressed. If you have a PayPal account, I will send you some beer money for this.
 
RiffRaff said:
That worked. I got a popup window notifying me of the DEFCON change to level 4 with the appropriate logo, and the system try icon is now displaying a blue 4. Here is the verbose error reporting, but I think it's really minor stuff with the GTK:
Code:
convert: unable to open image `/home/eric/DWS/DWS-linux/defcon.jpg': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: no images defined `txt:-' @ error/convert.c/ConvertImageCommand/3210.
./DWS-linux.sh: line 55: [: ==: unary operator expected
./DWS-linux.sh: line 58: [: ==: unary operator expected
No defcon image - is this the first run? Check INSTALL_DIR
stat: cannot stat 'defcon.jpg': No such file or directory
--2019-03-08 13:22:13--  https://defconwarningsystem.com/current/defcon.jpg
Resolving defconwarningsystem.com (defconwarningsystem.com)... 198.252.105.78
Connecting to defconwarningsystem.com (defconwarningsystem.com)|198.252.105.78|:443... 
(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:2559:14: 'min-height' is not a valid property name

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:4082:12: 'min-height' is not a valid property name

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:4083:11: 'min-width' is not a valid property name

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:6915:1: '/*' in comment block

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:7076:1: '/*' in comment block

(yad:13578): Gtk-WARNING **: Theme parsing error: gtk.css:7091:1: '/*' in comment block

(yad:13578): Gtk-WARNING **: Theme directory  of theme oxygen has no size field

connected.
HTTP request sent, awaiting response... 200 OK
Length: 51435 (50K) [image/jpeg]
Saving to: ‘/home/eric/DWS/DWS-linux/defcon.jpg’

defcon.jpg          100%[===================>]  50.23K  --.-KB/s    in 0.1s    

2019-03-08 13:22:13 (481 KB/s) - ‘/home/eric/DWS/DWS-linux/defcon.jpg’ saved [51435/51435]


(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:2559:14: 'min-height' is not a valid property name

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:4082:12: 'min-height' is not a valid property name

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:4083:11: 'min-width' is not a valid property name

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:6915:1: '/*' in comment block

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:7076:1: '/*' in comment block

(yad:13584): Gtk-WARNING **: Theme parsing error: gtk.css:7091:1: '/*' in comment block

(yad:13584): Gtk-WARNING **: Theme directory  of theme oxygen has no size field

Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

Edit: This is a nice compact script. You seem to be a follower of the KISS principle, and you believe in putting notes in your code. I'm very impressed. If you have a PayPal account I will send you some beer money for this.
 
Glad it's working! It seems that the Gtk warnings are not critical, just warnings. I think they result from internal yad settings, so for now, I'll let them be.

I do like to keep stuff simple - it makes it easier to debug, for one. I initially tried to create this program in Qt, but that ended up being rather complicated, and I found that yad would allow me to do it all through a script. So I went with that. I guess all it's missing now is handling for the other DEFCON levels.
 
Been running this app since this thread started. I'm not sure it's updating automatically. When we went from 4 to 5 my system tray icon remained at 4 until I did a manual refresh. And just now when DWS ran a system test for the desktop app nothing changed. Any thoughts on this?
 
I'm not sure - I did notice that when it changed from 4 to 5 only one of the two computers I'd been running it on updated at all... but the one that didn't update has other problems, so I didn't think much of it - I'll see if I can do more troubleshooting. Probably an issue with conditionals somewhere. One of my computers did work successfully, for what that's worth.

I don't think the app will update during a desktop app test - it directly checks the defconwarningsystem.com/current/defcon.jpg image to derive the state. And since it only checks every 5 minutes, it could miss a short-lived change.

Thanks for the heads-up!
 
iron_eagl said:
I'm not sure - I did notice that when it changed from 4 to 5 only one of the two computers I'd been running it on updated at all... but the one that didn't update has other problems, so I didn't think much of it - I'll see if I can do more troubleshooting. Probably an issue with conditionals somewhere. One of my computers did work successfully, for what that's worth.

I don't think the app will update during a desktop app test - it directly checks the defconwarningsystem.com/current/defcon.jpg image to derive the state. And since it only checks every 5 minutes, it could miss a short-lived change.

Thanks for the heads-up!

Use the file code.dat. That is where the alert code is stored. It is a single digit. 1, 2, 3, 4, or 5
 
That is very helpful. Thanks! That simplifies some of the code. And should also remove the dependency on ImageMagick.
 
That did simplify quite a lot. The script no longer depends on ImageMagick, and due to the decreased downloaded file sizes I now have wget fully download and then check (1 byte) the file each time, rather than relying on timestamping. I also switched the script to run on just the generic shell rather than bash specifically, in case that had something to do with your issue. Thanks for testing this out.
 
iron_eagl said:
That did simplify quite a lot. The script no longer depends on ImageMagick, and due to the decreased downloaded file sizes I now have wget fully download and then check (1 byte) the file each time, rather than relying on timestamping. I also switched the script to run on just the generic shell rather than bash specifically, in case that had something to do with your issue. Thanks for testing this out.

So is this available for download at this point?
 
I suppose so. Realistically, it's only been tested on 1-2 setups, so there might still be some tweaks that will need to be made for complete portability, and I'll need to see if it catches the next system test, but it should be fully functional for all DEFCON levels now. All the mentioned changes have been incorporated into the master branch on GitHub, so you can download the zip file either from that main page or from the most current release. Personally, I will recommend git-cloning into Documents, that's the default "install folder" for the script to be in, so updating in the future is a simple "git pull".
 
Okay, so what I'm getting now is an alert window popping up every 60 seconds telling me the DEFCON level has changed from green to green. Something is not picking up on when the alert level is unchanged, no new popup is needed.
 
Okay, I've been having a perhaps similar issue, it's taken me a while to figure out what it could be, it's not very repeatable. I think the issue comes in part from reading the value improperly, and thus going to an "empty" value, and then triggering it again when it correctly reads the value and updates it. Does it pop up only in pairs, 60 seconds apart, or is it truly every 60 seconds forever? You can stop the notifications by setting "NOTIFY=0" in the user config for now, I'll see if I can perhaps get it to catch the error and not notify if changing to an empty state or from one.
 
You are right. It pops up in pairs, 60 seconds apart.
 
All right. I changed the condition for notifying to also check if the "update" was due to not getting any data. Now it won't notify, it will just put up the "NC" icon for the next minute, or until it connects again, where it will then update with the current status, but won't notify. Not perfect - it's possible that the status could be 5, it could lose connection / skip a beat, and then when it reconnects and the status has changed to 4 it won't notify you. But it also won't notify you with those 60-second pairs, so that's good. I've been testing for the last 36 hours, it looks like that issue's solved. Updated script is on GitHub.
 
Okay, have the latest version installed. I'll let you know how it goes.
 
Top