DEFCON Desktop Linux app (UNOFFICIAL)

Feedback to the Admin and Staff of the DEFCON Warning System. Comments and suggestions welcome regarding the System or the Message Board or any part of the DEFCON Warning System.
iron_eagl
.
Posts: 10
Joined: Thu Mar 07, 2019 11:53 pm

Fri Mar 08, 2019 4:58 am

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

User avatar
DEFCONWarningSystem
Director
Director
Posts: 5704
Joined: Wed Aug 11, 2010 10:26 pm
Contact:

Fri Mar 08, 2019 5:22 am

I don't have Linux. I'd be curious to hear what people think of this.

User avatar
RiffRaff
DEFCON Data Analyst
DEFCON Data Analyst
Posts: 2095
Joined: Thu Apr 07, 2016 12:09 pm
Location: Indianapolis, Indiana, US
Contact:

Fri Mar 08, 2019 9:51 am

I run Linux on my laptop. I can download and test it.
"It's in your nature to destroy yourselves." - Terminator 2: Judgment Day

User avatar
RiffRaff
DEFCON Data Analyst
DEFCON Data Analyst
Posts: 2095
Joined: Thu Apr 07, 2016 12:09 pm
Location: Indianapolis, Indiana, US
Contact:

Fri Mar 08, 2019 10:37 am

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: Select all

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
"It's in your nature to destroy yourselves." - Terminator 2: Judgment Day

iron_eagl
.
Posts: 10
Joined: Thu Mar 07, 2019 11:53 pm

Fri Mar 08, 2019 4:00 pm

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: Select all

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.

User avatar
RiffRaff
DEFCON Data Analyst
DEFCON Data Analyst
Posts: 2095
Joined: Thu Apr 07, 2016 12:09 pm
Location: Indianapolis, Indiana, US
Contact:

Fri Mar 08, 2019 6:26 pm

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: Select all

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.
"It's in your nature to destroy yourselves." - Terminator 2: Judgment Day

iron_eagl
.
Posts: 10
Joined: Thu Mar 07, 2019 11:53 pm

Fri Mar 08, 2019 6:50 pm

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.

User avatar
RiffRaff
DEFCON Data Analyst
DEFCON Data Analyst
Posts: 2095
Joined: Thu Apr 07, 2016 12:09 pm
Location: Indianapolis, Indiana, US
Contact:

Sun Mar 17, 2019 9:28 pm

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?
"It's in your nature to destroy yourselves." - Terminator 2: Judgment Day

iron_eagl
.
Posts: 10
Joined: Thu Mar 07, 2019 11:53 pm

Sun Mar 17, 2019 10:01 pm

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!

User avatar
DEFCONWarningSystem
Director
Director
Posts: 5704
Joined: Wed Aug 11, 2010 10:26 pm
Contact:

Mon Mar 18, 2019 12:22 am

iron_eagl wrote:
Sun Mar 17, 2019 10:01 pm
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

Post Reply