Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Added helpful messages - I hope so - to TermMain before .rdy file wri…
Browse files Browse the repository at this point in the history
…ting
  • Loading branch information
GWhisk committed Mar 7, 2019
1 parent 2f4ec0e commit 6106431
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/jg/proj/kms/RdyFileUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static RdyFile parse(String workingDir, String ... lines) throws Exceptio
i++;
}

System.out.println("PARSED WHOLE COMMAND: "+enclosedCommand);
//System.out.println("PARSED WHOLE COMMAND: "+enclosedCommand);

//parse command name
String commandName = "";
Expand All @@ -103,7 +103,7 @@ public static RdyFile parse(String workingDir, String ... lines) throws Exceptio
}

commandName = commandName.trim();
System.out.println("---PARSED COMMAND NAME: |"+commandName+"|");
//System.out.println("---PARSED COMMAND NAME: |"+commandName+"|");

//check if command name is supported
Command command = null;
Expand Down
3 changes: 2 additions & 1 deletion src/jg/proj/kmsi/InstallMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public static void main(String [] args){

try {
PrintWriter writer = new PrintWriter(batchFile);
writer.println("javaw.exe -jar \""+new File(targetDir, "kmon.jar").getAbsolutePath()+"\"");
writer.println("@echo off");
writer.println("start javaw.exe -jar \""+new File(targetDir, "kmon.jar").getAbsolutePath()+"\"");
writer.flush();
writer.close();
System.out.println("* Startup file created. ");
Expand Down
Binary file modified src/jg/proj/kmsi/kmon.jar
Binary file not shown.
Binary file modified src/jg/proj/kmsi/kms.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion src/jg/proj/kmsi/patheditor.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$new_entry = $args[0]
# Credit to https://stackoverflow.com/a/37304698 for the code!
$new_entry = $args[0]

$old_path = [Environment]::GetEnvironmentVariable('path', 'machine');
$new_path = $old_path + ';' + $new_entry
Expand Down
109 changes: 109 additions & 0 deletions src/jg/proj/kmsterm/Diffuser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package jg.proj.kmsterm;

import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.net.URI;

public class Diffuser {

public static void entrance(){
//Separating kms prints with personal prints
for(int i = 0; i < 4; i++){
System.out.println(".");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
continue;
}
}

String potUserName = System.getProperty("user.name");

String [] messages = {
"Hey "+potUserName+". Is that your name?",
"I know this looks really creepy, but I just wanna ask you to breathe right now.",
"Our lives are often so stressful that we rarely reserve time to fill our lungs....",
"The human brain is such an incredibly powerful organ. If we restrict it of fresh oxygen....",
"... we start to cloud our thinking. Certain emotions take hold and we often end up ...",
"easily frustrated and angered. And when our breathing continues to shorten, these thoughts grow",
"And when they do, we sometimes think that everything in our lives is frustrating.",
"We become unmonitvated. Our passions weaken. And we get depressed.",
"We start comparing ourselves to others more and suddenly, we begin to live a life not by our own progress",
"But the progress of others.",
".....",
".....",
"You need to know though: this is your life",
"Your growth as a person is ... yours",
"When you start to compare your progress to that of others, you begin to loose...",
"... everything that makes you ... you.",
"When we start to bend to the standards of others, we begin to loose our own standards",
".....",
"I'm not saying that you should completely ignore everyone else.",
"But I am asking you to breathe...",
"Embrace who you are.",
"Embrace your struggles",
"Embrace your scars",
"Embrace your quirks",
"Embrace your failures",
"...In this moment, embrace yourself and think about your life so far.",
"and remember to breathe! We want all eyes on deck, not just frustration and anger",
", but also happiness, joy, love and hope.",
"Especially hope!",
"........................",
"........................",
"........................",
"........................",
};

for(String string : messages){
matrixPrint(string, 75);
sleep(500);
}

matrixPrint("Okay, you were probably hoping that I'd stop also. ", 75);
sleep(500);
matrixPrint("But before I do, let me try and get you some help...", 75);

//attempt to open browser
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) {
try {
Desktop.getDesktop().browse(new URI("https://suicidepreventionlifeline.org/"));
} catch (Exception e) {}
}

matrixPrint("1-800-273-8255 <--- National Suicide Prevention Lifeline", 75);
sleep(250);
matrixPrint("https://suicidepreventionlifeline.org/chat/ <---- Lifeline Chat", 75);
sleep(250);
matrixPrint("https://afsp.org/find-support/ive-lost-someone/find-a-support-group/ <---- Find a Support Group", 75);

matrixPrint("......................................", 75);
}

/**
* Will print the given message, but each character is printed
* at a delay of a set amount of miliseconds
* @param line - the message to print
* @param milisecPause - the amount of miliseconds to pause for
*/
private static void matrixPrint(String line, long milisecPause){
for(char c : line.toCharArray()){
System.out.print(c);
sleep(milisecPause);
}

System.out.print(System.lineSeparator());
}

/**
* Pauses the current thread for the given amount amount
* of milliseconds.
*/
private static void sleep(long milisecs){
try {
Thread.sleep(milisecs);
} catch (InterruptedException e) {
return;
}
}
}
23 changes: 23 additions & 0 deletions src/jg/proj/kmsterm/TermMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ public static void main(String[] args){
System.exit(-1);
}

//attempt to diffuse the situation
stopAndBreathe();
System.out.println(" Would you like to continue? (y/n) ");
Scanner scanner = new Scanner(System.in);
if (scanner.next().toLowerCase().startsWith("n")) {
scanner.close();
return;
}
scanner.close();

File rdyFileDir = new File(System.getProperty("user.home"), "kms/scripts/"+count+".rdy");
RdyFileUtility.writeRdyFile(rdyFile, rdyFileDir);

Expand All @@ -122,6 +132,11 @@ public static void main(String[] args){
Platform.exit();
}

/**
* Alerts kmonitor - the kms aspect that actually schedules .rdy scripts for execution - that a new .rdy
* is ready for scheduling.
* @return true if kmonitor was successfully alerted. False, if not.
*/
private static boolean alertKmonitor(){
int portNumber = 9999;
try {
Expand All @@ -136,6 +151,14 @@ private static boolean alertKmonitor(){
}
}

/**
* Tries to diffuse the situation and asks the user to re-asses their thoughts.
* If possible, it'll open the machine's default webrowser to helpful websites.
*/
private static void stopAndBreathe() {
Diffuser.entrance();
}

/**
* Reads and returns the current rdy file count
* @return returns the current rdy file count
Expand Down

0 comments on commit 6106431

Please sign in to comment.