You are not logged in.

#101 2019-01-09 12:33:11

S7.L
Member
Registered: 2018-09-16
Posts: 193

Re: The great yad hacking thread

^ yes thats it, thanks damo.

--button=gtk-cancel:1 \
--button="Killall Conky":kill-conky \

"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate."...Voilà!

~ V

Offline

#102 2019-01-09 13:54:07

S7.L
Member
Registered: 2018-09-16
Posts: 193

Re: The great yad hacking thread

Yad conky chooser v0.2. Bit better looking than the list option. Bunsenlabs conky manager is a work of art, much better control. I wonder is there ability for yad to do what bl conky manager can do?

2019-01-09--1547041697_467x305_scrot.th.png

#!/bin/bash

yad --title="Conky Chooser" --form --center --on-top --width=300 --height=200 --window-icon=utilities-system-monitor --width=250 \
--field="NL-Conky":fbtn 'conky -c "/home/s7/.config/conky/nl.conky.conf"' \
--field="BL-Top Conky":fbtn 'conky -c"/home/s7/.config/conky/BL conkys/BL-Top.conkyrc"' \
--field="Bar-Conky":fbtn 'conky -c "/home/s7/.config/conky/bar.conky.conf"' \
--button="Killall Conky":kill-conky \
--button="Restart Conky":conkyrestart \
--button=gtk-cancel:1

"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate."...Voilà!

~ V

Offline

#103 2019-01-09 19:48:02

damo
....moderator....
Registered: 2015-08-20
Posts: 4,488

Re: The great yad hacking thread

S7.L wrote:

... I wonder is there ability for yad to do what bl conky manager can do?

Well, the BL conky manager uses yad as the graphical interface for the script. Yad needs something behind the scenes to operate anything constructively!


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#104 2019-01-12 15:22:32

misko_2083
Member
Registered: 2016-05-24
Posts: 109

Re: The great yad hacking thread

Too bad there is no a way to detect anything within html dialog.

I haven't used that dialog much just played with some photo loading/preview.

https://i.imgur.com/Pugp1CRm.png
yad --width=800 --height=600 --html --uri=/home/misko/Desktop/test.html

test.html

 <!DOCTYPE html>
<html>
<body>



 <script src="https://code.jquery.com/jquery-2.2.4.min.js" async="async"></script>
    <link rel="stylesheet" media="all" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />

<style>
  .thumb {
    height: 300px;
    border: 1px solid #000;
    margin: 10px 5px 0 0;
  }
</style>

example 1

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="form1" runat="server">
  <input type='file' id="imgInp" />
  <img id="blah" class="thumb" src="#" alt="your image" />
</form>
<script>
function readURL(input) {

  if (input.files && input.files[0]) {
    var reader = new FileReader();

    reader.onload = function(e) {
      $('#blah').attr('src', e.target.result);
    }

    reader.readAsDataURL(input.files[0]);
  }
}

$("#imgInp").change(function() {
  readURL(this);
});

</script>

<p>example 2</p>



<input type="file" id="files" style="display:none" accept="image/x-png,image/gif,image/jpeg" name="files[]" multiple />
<a href="javascript:;" onclick="getImage()"/>
    <img src="/usr/share/icons/Faenza/actions/32/gtk-open.png"/>
</a>
<output id="list"></output>

<script>
     function getImage(){
       $('#files').click();
     }
</script>

<script>
  function handleFileSelect(evt) {
    var files = evt.target.files; // FileList object

    // Loop through the FileList and render image files as thumbnails.
    for (var i = 0, f; f = files[i]; i++) {

      // Only process image files.
      if (!f.type.match('image.*')) {
        continue;
      }

      var reader = new FileReader();

      // Closure to capture the file information.
      reader.onload = (function(theFile) {
        return function(e) {
          // Render thumbnail.
          var span = document.createElement('span');
          span.innerHTML = ['<img class="thumb" src="', e.target.result,
                            '" title="', escape(theFile.name), '"/>'].join('');
          document.getElementById('list').insertBefore(span, null);
        };
      })(f);

      // Read in the image file as a data URL.
      reader.readAsDataURL(f);
    }
  }

  document.getElementById('files').addEventListener('change', handleFileSelect, false);

</script>
</body>
</html> 

Last edited by misko_2083 (2019-01-12 15:24:36)

Offline

#105 2019-01-13 15:22:08

S7.L
Member
Registered: 2018-09-16
Posts: 193

Re: The great yad hacking thread

Using a bit different config...

yad --width 200 --height 400 --title "CONKY" --form --center --on-top --width=300 --height=200 --window-icon=utilities-system-monitor --width=250 \
    --form \
    --field="Conky Bar:BTN" 'conky -c  "/home/s7/.config/conky/bar.conky.conf"' \
    --field="Conky NL:BTN" 'conky -c  "/home/s7/.config/conky/nl.conky.conf"' \
    --field="Conky BL-Top:BTN" 'conky -c  "/home/s7/.config/conky/BL-Top.conf"' \
    --field="Restart Conky":fbtn "conkyrestart" \
    --field="Kill Conky":fbtn "kill-conky" \

2019-01-14-011841_1366x768_scrot.th.png

I would like to space those cancel and ok buttons better.

^just use this...

--button=gtk-close:1

Last edited by S7.L (2019-01-13 15:33:48)


"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate."...Voilà!

~ V

Offline

#106 2019-01-14 00:02:09

misko_2083
Member
Registered: 2016-05-24
Posts: 109

Re: The great yad hacking thread

^ I gave it a shot with --html and yad v.40

#!/bin/bash

stdbuf -oL -eL yad --title="Conky Chooser" \
                    --width=400 --height=250 \
                    --html --uri="/home/misko/Desktop/test2.html" \
                    --button=gtk-cancel:1 \
                    --print-uri 2>&1 \
| while read -r line; do
     case ${line##*/} in
      gg)
        conky -c  "/home/s7/.config/conky/bar.conky.conf" ;;
      bb)
        conky -c  "/home/s7/.config/conky/nl.conky.conf" ;;
      ee)
        conky -c  "/home/s7/.config/conky/BL-Top.conf" ;;
      restart)
        conkyrestart ;;
      kill)
        kill-conky ;;
      *) echo "unknown command" ;;
     esac
done

And here's "frontend" smile in test2.html
-javascript prevents context menu popup-

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.body {
  background-color: #CECECE;
}

.btn {
  border: 2px solid black;
  background-color: white;
  color: black;
  padding: 14px 28px;
  font-size: 16px;
  cursor: pointer;
}

/* Green */
.bar {
  border-color: #4CAF50;
  color: green;
  text-decoration: none;
}

.bar:hover {
  background-color: #4CAF50;
  color: white;
}

/* Blue */
.bl {
  border-color: #2196F3;
  color: dodgerblue;
  text-decoration: none;
}

.bl:hover {
  background: #2196F3;
  color: white;
  text-decoration: none;
}

/* Orange */
.bltop {
  border-color: #ff9800;
  color: orange;
  text-decoration: none;
}

.bltop:hover {
  background: #ff9800;
  color: white;
  text-decoration: none;
}

/* Red */
.restart{
  border-color: #f44336;
  color: red;
  text-decoration: none;
}

.restart:hover {
  background: #f44336;
  color: white;
}

/* Gray */
.default {
  border-color: #000000;
  color: black;
  text-decoration: none;
}

.default:hover {
  background: #000000;
  color: white;
  text-decoration: none;
}
</style>

<script type="text/javascript">
    if (document.addEventListener) { // IE >= 9; other browsers
        document.addEventListener('contextmenu', function(e) {
            //here you do nothing on right-click
            e.preventDefault();
        }, false);
    } else { // IE < 9
        document.attachEvent('oncontextmenu', function() {
            alert("You've tried to open context menu");
            window.event.returnValue = false;
        });
    }
</script>

</head>
<body class="body">

<div 
 style="-moz-user-select: none; -webkit-user-select: none; -ms-user-select:none; user-select:none;-o-user-select:none;" 
 unselectable="on"
 onselectstart="return false;" 
 onmousedown="return false;">
<h1>S7.Conky</h1>

<a href="gg" class="btn bar">Bar</a>
<a href="bb" class="btn bl">BL</a>
<a href="ee" class="btn bltop">BL-Top</a>
<br></br>
<br></br>
<a href="restart" class="btn restart">Restart Conky</a>
<a href="kill" class="btn default">Stop Conky</a>

</div>

</body>
</html>

Scrrenshot
4Uup5ez.gif
Sorry about bad looking buttons, I'm not a web developer. smile

Offline

#107 2019-01-15 11:16:54

S7.L
Member
Registered: 2018-09-16
Posts: 193

Re: The great yad hacking thread

^ Thats very cool misko thankyou, is that something like electron? I wouldnt have a clue how to do that sort of thing, ive dabbled a bit in html and css but not ever puting it together with say a bash script.


"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate."...Voilà!

~ V

Offline

#108 2019-01-16 14:06:20

misko_2083
Member
Registered: 2016-05-24
Posts: 109

Re: The great yad hacking thread

S7.L this is something like Ubuntu Mate Welcome screen. Except with UMW it's used python webkit for front end and in back end it's python. Like having two layers that communicate.
One that is used to interact with user and the other one to do everything else.

With python much more can be done with ease, like creating and modifying the front end.
With Yad's webkit that would probably be hard to do. Though as a simple launcher like "launch and forget" it can be useful.

Offline

Board footer

Powered by FluxBB