Added code and resources.

This commit is contained in:
Maxim Stewart 2016-07-18 18:01:43 -05:00
parent d51354706c
commit 4e5cec4615
9 changed files with 356 additions and 0 deletions

BIN
bin/v0.0.1/Controller.class Normal file

Binary file not shown.

BIN
bin/v0.0.1/XWWMenu.class Normal file

Binary file not shown.

3
bin/v0.0.1/launch.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
java XWWMenu

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?scenebuilder-background-color 0xbfbfbfff?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" style="-fx-background: #444444;&#10;" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="Controller">
<children>
<AnchorPane id="AnchorPane" fx:id="imgVideoField" layoutX="286.0" layoutY="46.0">
<children>
<ImageView fx:id="imgView" cache="false" cacheHint="SPEED" depthTest="INHERIT" fitHeight="375.0" fitWidth="500.0" pickOnBounds="true" preserveRatio="false" smooth="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<image>
<Image url="resources/startImg.jpg" backgroundLoading="false" />
</image>
</ImageView>
</children>
</AnchorPane>
<Label layoutX="18.0" layoutY="463.0" text="Right Screen Resolutions:" />
<Label layoutX="406.0" layoutY="479.0" text="Save Path:" />
<Label layoutX="18.0" layoutY="400.0" text="Left Screen Resolutions:" />
<Label fx:id="errorField" layoutX="337.0" layoutY="459.0" prefWidth="168.0" text="" textFill="#ff3333" />
<Label layoutX="14.0" layoutY="46.0" text="XScreenSaver List" />
<TextField id="dirPthField" fx:id="txtField" layoutY="14.0" prefWidth="531.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="55.0" />
<Button fx:id="dirBttn" layoutY="14.0" mnemonicParsing="false" onAction="#getImg" text="Dir" AnchorPane.rightAnchor="14.0" />
<Button fx:id="saveBttn" mnemonicParsing="false" onAction="#saveToFile" prefHeight="50.0" prefWidth="169.0" text="Save Selection" AnchorPane.bottomAnchor="27.0" AnchorPane.leftAnchor="391.0" AnchorPane.rightAnchor="240.0" AnchorPane.topAnchor="523.0" />
<Button fx:id="applyBttn" mnemonicParsing="false" onAction="#applySttngs" prefHeight="50.0" prefWidth="100.0" text="Apply" AnchorPane.bottomAnchor="27.0" AnchorPane.leftAnchor="577.5" AnchorPane.rightAnchor="122.5" AnchorPane.topAnchor="523.0" />
<Button fx:id="restartBttn" mnemonicParsing="false" onAction="#restartXWinWrp" prefHeight="50.0" prefWidth="170.0" text="RE-Start XWinWrap" AnchorPane.bottomAnchor="27.0" AnchorPane.leftAnchor="196.0" AnchorPane.rightAnchor="435.0" />
<Button fx:id="killBttn" mnemonicParsing="false" onAction="#killXWinWrp" prefHeight="50.0" prefWidth="170.0" text="Kill XWinWrap" AnchorPane.bottomAnchor="27.0" AnchorPane.leftAnchor="18.0" AnchorPane.rightAnchor="613.0" />
<Button fx:id="closeBttn" mnemonicParsing="false" onAction="#closeProg" prefHeight="50.0" prefWidth="100.0" text="Close" AnchorPane.bottomAnchor="27.0" AnchorPane.leftAnchor="686.0" AnchorPane.rightAnchor="14.0" />
<ChoiceBox fx:id="listSaveLoc" layoutY="479.0" prefHeight="29.0" prefWidth="283.0" AnchorPane.leftAnchor="482.5" AnchorPane.rightAnchor="34.5">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value=".animatedBGstarter.sh" />
<String fx:value=".animatedBGstarter2.sh" />
</FXCollections>
</items>
</ChoiceBox>
<ChoiceBox id="listRes" fx:id="listRgthRes" layoutY="479.0" prefHeight="29.0" prefWidth="169.0" value="+1920+0" AnchorPane.leftAnchor="18.0" AnchorPane.rightAnchor="613.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="+1920+0" />
<String fx:value="+1440+0" />
<String fx:value="+1600+0" />
<String fx:value="+1280+0" />
<String fx:value="+800+0" />
</FXCollections>
</items>
</ChoiceBox>
<ChoiceBox id="listRes" fx:id="listLftRes" layoutY="416.0" prefHeight="29.0" prefWidth="169.0" value="1920x1080" AnchorPane.leftAnchor="18.0" AnchorPane.rightAnchor="613.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1920x1080" />
<String fx:value="1440x720" />
<String fx:value="1600x900" />
<String fx:value="1280x720" />
<String fx:value="800x600" />
</FXCollections>
</items>
</ChoiceBox>
<CheckBox fx:id="lftScrn" layoutY="463.0" mnemonicParsing="false" prefWidth="114.17000000000002" selected="true" text="Left Screen" AnchorPane.leftAnchor="223.0" AnchorPane.rightAnchor="462.83" />
<CheckBox fx:id="rghtScrn" allowIndeterminate="false" layoutY="492.0" mnemonicParsing="false" prefWidth="114.17000000000002" text="Right Screen" AnchorPane.leftAnchor="223.0" AnchorPane.rightAnchor="462.83" />
<ListView fx:id="selXScreenSvr" layoutX="14.0" layoutY="62.0" onMouseClicked="#passXScreenVal" prefHeight="322.0" prefWidth="200.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="electricsheep " />
<String fx:value="atlantis" />
<String fx:value="atunnel " />
<String fx:value="blinkbox " />
<String fx:value="blocktube" />
<String fx:value="bouncingcow " />
<String fx:value="boxfit " />
<String fx:value="bsod" />
<String fx:value="bubble3d " />
<String fx:value="bumps " />
<String fx:value="cage" />
<String fx:value="carousel " />
<String fx:value="cube21 " />
<String fx:value="cubenetic" />
<String fx:value="cubicgrid " />
<String fx:value="cwaves " />
<String fx:value="dangerball" />
<String fx:value="fiberlamp " />
<String fx:value="fireworkx " />
<String fx:value="flipflop" />
<String fx:value="fliptext " />
<String fx:value="flow " />
<String fx:value="flurry" />
<String fx:value="flyingtoasters " />
<String fx:value="gflux " />
<String fx:value="glcells" />
<String fx:value="gleidescope " />
<String fx:value="glknots " />
<String fx:value="glmatrix" />
<String fx:value="glschool " />
<String fx:value="glslideshow " />
<String fx:value="glsnake" />
<String fx:value="hypertorus " />
<String fx:value="hypnowheel " />
<String fx:value="interaggregate" />
<String fx:value="intermomentary " />
<String fx:value="jigglypuff " />
<String fx:value="jigsaw" />
<String fx:value="julia " />
<String fx:value="lament " />
<String fx:value="lockward" />
<String fx:value="metaballs " />
<String fx:value="moebiusgears " />
<String fx:value="molecule" />
<String fx:value="morph3d " />
<String fx:value="noof " />
<String fx:value="phosphor" />
<String fx:value="photopile " />
<String fx:value="pinion " />
<String fx:value="popsquares" />
<String fx:value="ripples " />
<String fx:value="skytentacles " />
<String fx:value="slidescreen" />
<String fx:value="stonerview " />
<String fx:value="strange " />
<String fx:value="substrate" />
<String fx:value="tangram " />
<String fx:value="whirlwindwarp " />
<String fx:value="wormhole" />
<String fx:value="xflame " />
<String fx:value="xrayswarm " />
<String fx:value="companioncube" />
<String fx:value="fuzzyflakes " />
<String fx:value="galaxy " />
<String fx:value="glplanet" />
<String fx:value="penetrate" />
</FXCollections>
</items>
</ListView>
<CheckBox fx:id="useXSvrn" layoutX="223.0" layoutY="437.0" mnemonicParsing="false" text="Use XScreenSaver" />
</children>
</AnchorPane>

View File

@ -0,0 +1,5 @@
#!/bin/bash
### nohup is needed to keep child process alive from java's
xterm -e nohup ~/.animatedBGstarter.sh
xterm -e nohup ~/.animatedBGstarter2.sh

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

189
src/v0.0.1/Controller.java Normal file
View File

@ -0,0 +1,189 @@
import javafx.stage.Stage;
import javafx.fxml.FXML;
import javafx.stage.FileChooser;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.scene.media.Media;
import javafx.scene.media.MediaView;
import javafx.scene.media.MediaPlayer;
import javafx.scene.control.*;
import javafx.event.ActionEvent;
import java.io.*;
public class Controller {
private FileChooser fileChooser = new FileChooser();
private String tmpPath, resolution, xScreenVal, output,
startScrpt = System.getProperty("user.dir") + "/resources/bin/StartXWW.sh",
ffmpg = System.getProperty("user.dir") + "/resources/bin/ffmpegthumbnailer";
private int applyType = 1;
private Stage fileChooserStage;
private Image imgPath;
private Process pb;
private File file;
private FileWriter fileWriter;
@FXML private AnchorPane imgVideoField;
@FXML private ImageView imgView;
@FXML private ListView<?> selXScreenSvr;
@FXML private TextField txtField;
@FXML private Label errorField;
@FXML private CheckBox lftScrn, rghtScrn, useXSvrn;
@FXML private ChoiceBox<?> listLftRes, listRgthRes, listSaveLoc;
@FXML private Button applyBttn, closeBttn, dirBttn,
killBttn, restartBttn, saveBttn;
@FXML
void closeProg(ActionEvent event) {
System.exit(0);
}
@FXML
void getImg(ActionEvent event) throws Exception {
fileChooser.setTitle("Open Image File");
tmpPath = "" + fileChooser.showOpenDialog(fileChooserStage);
txtField.setText(tmpPath);
if (txtField.getText().toLowerCase().contains(".mp4") ||
txtField.getText().toLowerCase().contains(".mkv") ||
txtField.getText().toLowerCase().contains(".mpg") ||
txtField.getText().toLowerCase().contains(".wmv") ||
txtField.getText().toLowerCase().contains(".flv")) {
/* ########## FOR FUTURE PLAYING VIDEO ##########
pb = new ProcessBuilder("mplayer", "-slave", "-quiet", "-idle", tmpPath).start();
Media media = new Media(getClass().getResource("test.mp4").toString());
// Create the player and set to play automatically.
final MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
final MediaView mediaView = new MediaView(mediaPlayer);
imgVideoField.getChildren().clear();
imgVideoField.getChildren().addAll(mediaView);
*/
String movieImg = ffmpg + " -w -t='00:10:00' -c jpg -i " + tmpPath +
" -s 800 -o /tmp/image.jpg";
pb = Runtime.getRuntime().exec(movieImg);
imgPath = new Image("file://" + "/tmp/image.jpg");
tmpPath = "/tmp/image.jpg";
}
else
imgPath = new Image("file://" + tmpPath);
imgView.setFitWidth(500);
imgView.setFitHeight(375);
imgView.setImage(imgPath);
String title = "" + tmpPath;
final ImageView imgViewPoped = new ImageView("file://" + tmpPath);
setClick(imgViewPoped, title);
if(txtField.getText().toLowerCase().contains(".jpg") ||
txtField.getText().toLowerCase().contains(".png"))
applyType = 2;
}
void setClick(ImageView imgViewPoped, String title) {
imgView.setOnMouseClicked(e -> {
imgViewPoped.setLayoutX(0);
imgViewPoped.setLayoutY(0);
Stage popOut = new Stage();
Pane pane = new Pane();
imgViewPoped.fitWidthProperty().bind(pane.widthProperty());
imgViewPoped.fitHeightProperty().bind(pane.heightProperty());
pane.getChildren().addAll(imgViewPoped);
Scene scene = new Scene(pane, 800, 600);
popOut.setTitle(title);
popOut.setScene(scene);
popOut.show();
});
}
@FXML
void killXWinWrp(ActionEvent event) throws Exception {
pb = Runtime.getRuntime().exec("killall xwinwrap &");
}
@FXML
void restartXWinWrp(ActionEvent event) throws Exception {
pb = Runtime.getRuntime().exec("killall xwinwrap &");
pb = Runtime.getRuntime().exec(startScrpt);
}
@FXML
void passXScreenVal() {
xScreenVal = "" + selXScreenSvr.getSelectionModel().getSelectedItem();
}
@FXML
void saveToFile(ActionEvent event) throws Exception {
// Saves to file with selected and needed settings
if(txtField.getText().toLowerCase().contains(".jpg") ||
txtField.getText().toLowerCase().contains(".png"))
file = new File(System.getProperty("user.home") + "/" + ".config/nitrogen/bg-saved.cfg");
else
file = new File(System.getProperty("user.home") + "/" + listSaveLoc.getValue());
fileWriter = new FileWriter(file);
errorField.setText("");
if (lftScrn.isSelected() == true && rghtScrn.isSelected() == true)
errorField.setText("Please only check one...");
else if (lftScrn.isSelected() == false && rghtScrn.isSelected() == false)
errorField.setText("Please check one...");
else if (lftScrn.isSelected() == true && rghtScrn.isSelected() == false) {
resolution = "" + listLftRes.getValue();
startSave();
}
else if (rghtScrn.isSelected() == true && lftScrn.isSelected() == false) {
resolution = "" + listLftRes.getValue() + "" + listRgthRes.getValue();
startSave();
} else { startSave(); }
}
void startSave() throws Exception {
// XSCREENSAVER
if (useXSvrn.isSelected() == true) {
output = "xwinwrap -ov -g " + resolution + " -st -sp -b -nf -s -ni -- /usr/lib/xscreensaver/" + xScreenVal + " -window-id WID -root";
fileWriter.write(output);
applyType = 1;
// GIF
} else if (txtField.getText().toLowerCase().contains(".gif")) {
output = "xwinwrap -ov -g " + resolution + " -st -sp -b -nf -s -ni -- gifview -a -w WID " + txtField.getText();
fileWriter.write(output);
applyType = 1;
// Standard images using nitrogen
} else if(txtField.getText().toLowerCase().contains(".jpg") ||
txtField.getText().toLowerCase().contains(".png")) {
output = "[xin_0] \n file=" + txtField.getText() + "\nmode=0 \nbgcolor=#000000\n" +
"[xin_1] \nfile=" + txtField.getText() + "\nmode=0 \nbgcolor=#000000";
fileWriter.write(output);
applyType = 2;
//VIDEO
} else {
output = "xwinwrap -ov -g " + resolution + " -st -sp -b -nf -s -ni -- mplayer -wid WID -nosound -loop 0 " + txtField.getText();
fileWriter.write(output);
applyType = 1;
}
fileWriter.close();
}
@FXML
void applySttngs(ActionEvent event) throws Exception {
pb = Runtime.getRuntime().exec("killall xwinwrap &");
if (applyType == 1) {
pb = Runtime.getRuntime().exec(startScrpt);
} else if (applyType == 2) {
pb = Runtime.getRuntime().exec("nitrogen --restore");
} else
pb = Runtime.getRuntime().exec("nitrogen --restore");
}
@FXML
void initialize() {
assert applyBttn != null : "fx:id=\"applyBttn\" was not injected: check your FXML file 'Window.fxml'.";
assert closeBttn != null : "fx:id=\"closeBttn\" was not injected: check your FXML file 'Window.fxml'.";
assert dirBttn != null : "fx:id=\"dirBttn\" was not injected: check your FXML file 'Window.fxml'.";
assert errorField != null : "fx:id=\"errorField\" was not injected: check your FXML file 'Window.fxml'.";
assert imgVideoField != null : "fx:id=\"imgVideoField\" was not injected: check your FXML file 'Window.fxml'.";
assert imgView != null : "fx:id=\"imgView\" was not injected: check your FXML file 'Window.fxml'.";
assert killBttn != null : "fx:id=\"killBttn\" was not injected: check your FXML file 'Window.fxml'.";
assert lftScrn != null : "fx:id=\"lftScrn\" was not injected: check your FXML file 'Window.fxml'.";
assert listLftRes != null : "fx:id=\"listLftRes\" was not injected: check your FXML file 'Window.fxml'.";
assert listRgthRes != null : "fx:id=\"listRgthRes\" was not injected: check your FXML file 'Window.fxml'.";
assert listSaveLoc != null : "fx:id=\"listSaveLoc\" was not injected: check your FXML file 'Window.fxml'.";
assert restartBttn != null : "fx:id=\"restartBttn\" was not injected: check your FXML file 'Window.fxml'.";
assert rghtScrn != null : "fx:id=\"rghtScrn\" was not injected: check your FXML file 'Window.fxml'.";
assert saveBttn != null : "fx:id=\"saveBttn\" was not injected: check your FXML file 'Window.fxml'.";
assert selXScreenSvr != null : "fx:id=\"selXScreenSvr\" was not injected: check your FXML file 'Window.fxml'.";
assert txtField != null : "fx:id=\"txtField\" was not injected: check your FXML file 'Window.fxml'.";
assert useXSvrn != null : "fx:id=\"useXSvrn\" was not injected: check your FXML file 'Window.fxml'.";
}
}

18
src/v0.0.1/XWWMenu.java Normal file
View File

@ -0,0 +1,18 @@
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
public class XWWMenu extends Application {
@Override
public void start(Stage stage) throws Exception {
Scene scene = new Scene(FXMLLoader.load(XWWMenu.class.getResource("resources/Window.fxml")));
stage.setScene(scene);
stage.setTitle("XWinWrap Menu");
stage.setResizable(false);
stage.show();
}
public static void main(String[] args) { launch(args); }
}