Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - misko_2083

Pages: 1 ... 3 4 [5]
61
Scripts / gtk3 Volume Control for tint2
« on: December 17, 2015, 01:24:04 AM »
My attempt to make a volume control context menu that launches from tint2.
Uses amixer
It wasn't showing properly untill I've installed libgtk-3-0
Here is the launcher =>
/usr/local/bin/tint2launchers/07-sound.desktop
Code: [Select]
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Sound
Exec=python3 /usr/local/bin/menu.py
Icon=audio-headphones
NoDisplay=false

py script
/usr/local/bin/menu.py
Code: [Select]
#!/usr/bin/env python3
#  Milos Pavlovic 2015 <mpsrbija@gmail.com>
#
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.

#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.


import os
import sys
import string
import subprocess
import shlex
from gi import require_version
require_version("Gtk", "3.0")
from gi.repository import Gtk
from gi.repository.GdkPixbuf import Pixbuf

def execute(command):
    """function to exec switch"""
    p = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    return p.stdout

class Menu:

    def destroy(self, widget, data=None):
        Gtk.main_quit()

    def action(self, widget, event, execc, data=None):
        command = execc
        subprocess.Popen(shlex.split(command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        Gtk.main_quit()

    def __init__(self):
        self.menu = Gtk.Menu()
        """ This is how we close the script
            connecting to the hide signal
        """
        self.menu.connect("hide", self.destroy)
        it=Gtk.IconTheme.get_default()
        height = 100 # Height workaround

        button= Gtk.Switch()
        button.connect("notify::active", self.on_switch_activated)
        cmd = 'amixer get Master | grep -q  off ; echo $?'
        result1 = os.popen(cmd)
        result1 = result1.readline()
        if int(result1) == 0:
           button.set_active(False)
        else:
           button.set_active(True)
        box = Gtk.Box(homogeneous =True)
        img = Gtk.Image(xalign=0)
        pixbuf=it.load_icon("emblem-sound",24,0)
        img.set_from_pixbuf(pixbuf)
        box.add(img)
        box.add(button)
        menuitem = Gtk.MenuItem()
        menuitem.add(box)
        menuitem.connect("button-press-event", self.mute_clicked)
        menuitem.show()
        self.menu.append(menuitem)

# adjustment (initial value, min value, max value,
        # step increment - press cursor keys to see!,
        # page increment - click around the handle to see!,
        # page size - not used here)
        ad1 = Gtk.Adjustment(0, 0, 100, 5, 10, 0)
        cmd = "/usr/bin/amixer sget Master | grep '\[' "
        result = os.popen(cmd)
        result = result.readline()
        find_start = result.find('[') + 1
        find_end = result.find('%]', find_start)
        audio_level = int(result[find_start:find_end])
        ad1. set_value(audio_level)
        # an horizontal scale
        self.h_scale = Gtk.Scale(
            orientation=Gtk.Orientation.HORIZONTAL, adjustment=ad1)
        # of integers (no digits)
        self.h_scale.set_digits(0)
        # that can expand horizontally if there is space in the grid
        self.h_scale.set_hexpand(True)
        # that is aligned at the top of the space allowed in the grid
        self.h_scale.set_valign(Gtk.Align.START)

        # we connect the signal "value-changed" emitted by the scale with the callback
        # function scale_moved
        self.h_scale.connect("value-changed", self.scale_moved)
        box = Gtk.Box()
        box.add(self.h_scale)
        menuitem = Gtk.MenuItem()
        menuitem.add(box)
        menuitem.show()
        self.menu.append(menuitem)

        self.menu.set_size_request(180, height) # Workaround for height
        self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
        self.menu.show_all()

    # Let's set the voulume here
    def scale_moved(self, event):
        val = "{0}".format(int(self.h_scale.get_value()))
        proc = subprocess.Popen('/usr/bin/amixer sset Master ' + str(val) + '%  2>&1 >/dev/null', shell=True, stdout=subprocess.PIPE)
        proc.wait()

    def on_switch_activated(self, switch, gparam):
        if switch.get_active():
            execute('amixer set Master unmute 2>&1 >/dev/null')
            state = "on"
        else:
            execute('amixer set Master mute 2>&1 >/dev/null')
            state = "off"

    # Here we toogle the mute on and off when menuitem is clicked   
    def mute_clicked(self, event, data=None):
        val = "toggle"
        proc = subprocess.Popen('/usr/bin/amixer set Master ' + str(val) + '  2>&1 >/dev/null', shell=True, stdout=subprocess.PIPE)
        proc.wait()

    def main(self):
        Gtk.main()

if __name__ == "__main__":

     app = Menu()
     app.main()
The script closes when clicked outside of the menu.
There is a mute switch but will work as a button also.
reference from here >>> http://vsido.org/index.php?topic=1089.msg12301#msg12301

62
Artwork & Screenshots / Re: December 2015 Screenshot Thread
« on: December 16, 2015, 12:19:19 PM »
Made a little Gtk3 volume control to control volume. Launches from tint2   ;)
Just had to install some Gtk3 dependancies to work.


63
General Support / Re: How to emulate the mouse mid-click with a keystroke?
« on: September 23, 2015, 09:11:14 PM »
Yup, not working.
Code: [Select]
xbindkeys -n

*** Warning ***
Please verify that there is not another program running
which captures one of the keys captured by xbindkeys.
It seems that there is a conflict, and xbindkeys can't
grab all the keys defined in its configuration file.

Need to find out the conflict. No idea of what it can be.
Try some other key combo.
Setting F12 works for me.

64
General Support / Re: How to emulate the mouse mid-click with a keystroke?
« on: September 23, 2015, 05:10:04 PM »
You could bind some key or key combination with
Code: [Select]
xdotool click 2Need to install Xbindkeys
Code: [Select]
sudo apt-get install xbindkeysNow create a sample file
Code: [Select]
xbindkeys -d > ~/.xbindkeysrcThere are some good examples in that file
Edit the file
Code: [Select]
medit ~/.xbindkeysrcadd next
Code: [Select]
"xdotool click 2"
   F12
Start xbindkeys
Code: [Select]
xbindkeys &Now test with F12

You can set some other key or key combo.
Code: [Select]
xbindkeys -kA blank window will pop up. Press the key(s) to which you wish to assign a command and xbindkeys will output a handy snippet that can be entered into ~/.xbindkeysrc
Then edit the ~/.xbindkeysrc accordingly.
Now restart the xbinkeys daemon.
Code: [Select]
killall xbindkeys
xbindkeys -f ~/.xbindkeysrc

in case it doesn't work use -n to see why
Code: [Select]
xbindkeys -n
Remember to add "xbindkeys &" to your autostart.sh so it always runs when you start up.

You can also assign scroll up and down.
Code: [Select]
xdotool click 4
Code: [Select]
xdotool click 5Scrolls just a bit but you could add a few clicks in the command
Code: [Select]
xdotool click 4 click 4 click 4 click4

65
VSIDO Changes / Re: (SOLVED) Yad startup script for ceni
« on: July 30, 2015, 12:16:06 PM »
Wow, very nice work misko_2083!

Any reason as to why python would be a better choice? 

Thank you
It's all the same.
For example this is the equivalent of hakerdefo's script:
Code: [Select]
#!/usr/bin/env python3
#vsido-start.py
from gi.repository import Gtk, Gdk
import os
import sys
import subprocess
from subprocess import Popen
from gi.repository.GdkPixbuf import Pixbuf


icon="/usr/local/bin/images/vsidoorb_blk.png"

# Which
def which(program):
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file
    return None

class VsidoStartWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="VSIDO Message Center")

        self.set_default_size(-1, 450)


        self.grid = Gtk.Grid()
        self.add(self.grid)


        self.create_label()
        self.create_buttons()


    def create_label(self):
        label = Gtk.Label()
        label.set_markup("Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates"
                          "\n\n"
                          "It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options"
                          "\n\n"
                          "Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established")
        label.set_line_wrap(True)
        label.set_size_request(450, -1)


        table = Gtk.Table(1, 1, False)
        table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
        self.grid.attach(table, 1, 0, 2, 1)

    def create_buttons(self):

        button1 = Gtk.Button(label="Run Ceni")
        button1.connect("clicked", self.on_open_clicked)
        self.grid.attach(button1, 1, 2, 1, 1)

        button2 = Gtk.Button(label="Run Wicd")
        button2.connect("clicked", self.on_click_me_clicked)
        self.grid.attach_next_to(button2, button1, Gtk.PositionType.RIGHT, 1, 1)

        button3 = Gtk.Button(label="_Close", use_underline=True)
        button3.connect("clicked", self.on_close_clicked)
        self.grid.attach(button3,  1, 3, 3, 1)

    def on_click_me_clicked(self, button):
        checking = which("wicd-gtk")
        if checking == None:
           print("wicd-gtk not found")
           dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.INFO,
              Gtk.ButtonsType.OK, "VSIDO Message Center")
           dialog.format_secondary_text(
              "'wicd-gtk' can not be found.\nNothing to execute.")
           dialog.set_name('VsidoStart')
           dialog.run()
           dialog.destroy()
        else:
           cmd = "sudo systemctl status wicd | grep -c dead"
           wicdd = os.popen(cmd)
           wicdd = wicdd.readline()

   
           cmd = "sudo systemctl is-enabled wicd | grep -c disabled"
           wicdb = os.popen(cmd)
           wicdb = wicdb.readline()

           if int(wicdd) == 1:
              dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.QUESTION,
                 Gtk.ButtonsType.YES_NO, "VSIDO Message Center", title="VSIDO Message Center")
              dialog.format_secondary_text(
               "You have decided to use Wicd. Wicd service is not running. \nDo you want to start Wicd service?")
              response = dialog.run()

              if response == Gtk.ResponseType.YES:
                os.system('sudo systemctl start wicd')
                dialog.destroy()
              elif response == Gtk.ResponseType.NO:
                dialog.destroy()

           if int(wicdb) == 1:
              dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.QUESTION,
                 Gtk.ButtonsType.YES_NO, "VSIDO Message Center")
              dialog.format_secondary_text(
                 "Wicd service is disabled from autostarting.\nDo you want to enable Wicd autostart?")
              response_disable = dialog.run()
              if response_disable == Gtk.ResponseType.YES:
                 os.system('sudo systemctl enable wicd')
                 dialog.destroy()
              elif response_disable == Gtk.ResponseType.NO:
                 print("wicd not enabled")
              dialog.destroy()
           Popen('/bin/bash -c "wicd-gtk -n &>/dev/null &"', shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
           Gtk.main_quit()
    def on_open_clicked(self, button):
        #check if ceni exists
        checking = which("ceni")
        if checking == None:
           print("ceni not found")
           dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.INFO,
              Gtk.ButtonsType.OK, "VSIDO Message Center")
           dialog.format_secondary_text(
              "'ceni' can not be found.\nNothing to execute.")
           dialog.set_name('VsidoStart')
           dialog.run()
           dialog.destroy()
        else:
           cmd = "sudo systemctl status wicd | grep -c dead"
           wicdd = os.popen(cmd)
           wicdd = wicdd.readline()

   
           cmd = "sudo systemctl is-enabled wicd | grep -c disabled"
           wicdb = os.popen(cmd)
           wicdb = wicdb.readline()

           if int(wicdd) < 1:
              dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.QUESTION,
                 Gtk.ButtonsType.YES_NO, "VSIDO Message Center", title="VSIDO Message Center")
              dialog.format_secondary_text(
               "You have decided to use Ceni. Wicd is no longer needed. Stop Wicd?")
              response = dialog.run()

              if response == Gtk.ResponseType.YES:
                os.system('sudo systemctl stop wicd')
                dialog.destroy()
              elif response == Gtk.ResponseType.NO:
                dialog.destroy()

           if int(wicdb) < 1:
              dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.QUESTION,
                 Gtk.ButtonsType.YES_NO, "VSIDO Message Center")
              dialog.format_secondary_text(
                 "You have decided to use Ceni. Wicd is no longer needed. Disable Wicd?")
              response_disable = dialog.run()
              if response_disable == Gtk.ResponseType.YES:
                 os.system('sudo systemctl disable wicd')
              elif response_disable == Gtk.ResponseType.NO:
                dialog.destroy()

           Popen('/bin/bash -c "xfce4-terminal -e ceni &>/dev/null &"', shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
           Gtk.main_quit()
    def on_close_clicked(self, button):
        print("Closing VSIDO Message Center")
        Gtk.main_quit()

window = VsidoStartWindow()     
window.connect("delete-event", Gtk.main_quit)
window.set_resizable(False)
window.set_position(Gtk.WindowPosition.CENTER),
window.set_icon(Pixbuf.new_from_file("{0}".format(icon)))
window.set_name('VsidoStart')
style_provider = Gtk.CssProvider()
css = """
#VsidoStart {
    background: black;
    background-repeat: no-repeat;
    background-position: 0px 0px;
    color: #FFF;
    font: 20px sans-serif;

}
.button {
    font: 15px sans-serif;
    background: teal;
    -webkit-transition: color 1s;
    transition: color 1s;
    border: 1px solid #000;
    color: white;
    padding-top: 10px;
    padding-right: 20px;
    padding-bottom: 10px;
    padding-left: 20px;
}
.button:hover{
    background-color: #E3E1B8;
    font: 15px sans-serif;
    border: 1px solid #000;
    color: navy;
}
.dialog {
    background-repeat: no-repeat;
    background-position: 0px 0px;
    color: #FFF;
}
"""

style_provider.load_from_data(css.encode())

Gtk.StyleContext.add_provider_for_screen(
    Gdk.Screen.get_default(),
    style_provider,     
    Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
window.show_all()
Gtk.main()
I assume he intended to run it with sudo. Same problem here, it starts Wicd GTK interface with elevated privileges.
Just played a little with css here. Python and Css are a great combo.

Edit.............................................................
Perhaps it's better to stick with yad. I'd like to help but who knows wheater I will have the time.
I have a few other things on my mind. We are making a control center and Ubuntu 14.04.3 will be out in a few days so I'll be busy next month as we prepareing a new release.
Cheers :)

66
VSIDO Changes / Re: Yad startup script for ceni
« on: July 28, 2015, 01:13:41 AM »
@ misko_2083

Thanks for that!  I will look more into making the script a cosmetic makeover
I see you've managed to make Yad script working the way you want.
In the meantime I made vsido-start.py Not as fancy as YAD though.  :P Some python and gtk3+.

Code: [Select]
#!/usr/bin/env python3
#vsido-start.py
from gi.repository import Gtk
from subprocess import Popen
from gi.repository.GdkPixbuf import Pixbuf

icon="/usr/local/bin/images/vsidologo.png"

class LabelWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="VSIDO Message Center")

        self.set_default_size(-1, 450)


        self.grid = Gtk.Grid()
        self.add(self.grid)


        self.create_label()
        self.create_buttons()


    def create_label(self):
        label = Gtk.Label()
        label.set_markup("Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates"
                          "\n\n"
                          "It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options"
                          "\n\n"
                          "Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established")
        label.set_line_wrap(True)
        label.set_size_request(450, -1)


        table = Gtk.Table(1, 1, False)
        table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
        self.grid.attach(table, 1, 0, 2, 1)

    def create_buttons(self):

        button1 = Gtk.Button(label="Run Ceni")
        button1.connect("clicked", self.on_open_clicked)
        self.grid.attach(button1, 1, 2, 1, 1)

        button2 = Gtk.Button(label="Run Wicd")
        button2.connect("clicked", self.on_click_me_clicked)
        self.grid.attach_next_to(button2, button1, Gtk.PositionType.RIGHT, 1, 1)

        button3 = Gtk.Button(label="_Close", use_underline=True)
        button3.connect("clicked", self.on_close_clicked)
        self.grid.attach(button3,  1, 3, 3, 1)

    def on_click_me_clicked(self, button):
        Popen('/bin/bash -c "wicd-gtk -n &>/dev/null &"', shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
        Gtk.main_quit()
    def on_open_clicked(self, button):
        Popen('/bin/bash -c "xfce4-terminal -e ceni &>/dev/null &"', shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
        Gtk.main_quit()
    def on_close_clicked(self, button):
        print("Closing VSIDO Message Center")
        Gtk.main_quit()

window = LabelWindow()     
window.connect("delete-event", Gtk.main_quit)
window.set_resizable(False)
window.set_position(Gtk.WindowPosition.CENTER),
window.set_icon(Pixbuf.new_from_file("{0}".format(icon)))
window.show_all()
Gtk.main()
It looks like this:

67
Zenity & Yad / A little GUI tool to analyze the content of usb drives
« on: July 24, 2015, 07:38:09 PM »
This will display all of your mounted usb drives, then you select one.
The script will analyze the contents of the drive and display info about file types and size that file type takes on a drive.
I took some code from "makethumb" script and modified it for my needs.
As you can see it tell me how much space are images taking on this usb drive.

Code: [Select]
#!/bin/bash
# A GUI tool to analyze the usb drive content
# Misko
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# 3 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

# Make temporary file
list=$(mktemp /tmp/XXXXXX)

# get a list of devices
devs=`ls -al /dev/disk/by-path/*usb*part* 2>/dev/null | awk '{print($11)}'`
if [[ ${?} != 0 || -z ${devs} ]]
then
    zenity --warning --text "No USB Mounted!"
    exit
fi

# Initialize list and make sure it is empty
>$list

# Now get the info about our devices and put it in a list
for dev in $devs; do dev="${dev##*\/}";
    echo "FALSE" >> $list;
    echo -n "$dev" >> $list;
    echo " " >> $list;
    echo `cat /sys/block/${dev:0:3}/device/vendor 2>/dev/null` >> $list;
    echo `cat /sys/block/${dev:0:3}/device/model 2>/dev/null` >> $list;
    echo `lsblk 2>/dev/null | grep \`echo -E ${dev}\` |awk '{print($4)}' `B >> $list;
    echo `lsblk 2>/dev/null | grep \`echo -E ${dev}\` |cut -c 37- ` >> $list;
    echo -n `lsblk -o NAME 2>/dev/null | grep \`echo -E ${dev}\`| awk '{print($2)}'  ` >> $list;
    df -T `echo -E /dev/${dev}` 2>/dev/null | tail -1 | awk '{print $2}' >> $list;
    echo `ls -l /dev/disk/by-uuid/ 2>/dev/null | grep \`echo -E ${dev}\`| awk '{print($9)}' ` >> $list;
        done


# clear our array
devfs=()

# read in the array using a line tmp variable. This let's zenity see it line by line
while read -r line
do
    devfs+=("$line")
done < $list

rm $list
unset list

#Display the main dialog
disktmp=$(zenity --list --text="Select your USB drive from the list and click OK to begin.\nThis will calculate what file types you have on the drive and how much space do they consume.\nThe speed of this process depends on the drive size and on the number of files." --radiolist  --width=650 --height=350 --column="Pick" --column="Dev" --column="Vendor" --column="Model" --column="Size" --column="Mount" --column="FS" --column="UUID" "${devfs[@]}" --separator=":")

#Test for cancellation
if [[ ${?} != 0  ]]
then
    exit 0
fi

#Check if anything was selected
echo ${disktmp} | grep ^[0-9a-zA-Z] &>/dev/null
if [[ ${?} != 0  ]]
then
    zenity --info --text="Nothing was selected..." --timeout=10
    exit 0
fi
# Extract device
disk=${disktmp:0:4}

# Start calculating file sizes and convert bytes to human readable
{
echo "#Please wait, this may take a while"
find "$(echo `lsblk 2>/dev/null | grep \`echo -E ${disk}\` |cut -c 37- `)" -type f -exec file -b '{}' \; -printf '%s\n' | awk -F , 'NR%2 {i=$1} NR%2==0 {a[i]+=$1} END {for (i in a) printf("%12u %s\n",a[i],i)}' | sed -e 's/^[ \t]*//' > ~/usbinform
echo "#Calculating File size"
awk '{print $1}' ~/usbinform | awk '{ sum=$1 ; hum[1024**3]="GiB";hum[1024**2]="MiB";hum[1024]="KiB"; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x];break } if (sum<1024) {printf sum" bytes\n";break } }}' > ~/usbinform1
awk '{print $1}' ~/usbinform | awk '{ sum=$1 ; hum[1000**3]="GB";hum[1000**2]="MB";hum[1000]="KB"; for (x=1000**3; x>=1000; x/=1000){ if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x];break } if (sum<1000) {printf sum" bytes\n";break } }}' > ~/usbinform2
sed -i 's/\w*.//' ~/usbinform
} | zenity --progress --pulsate --auto-close || exit

# Display results
paste -d'\n' ~/usbinform2 ~/usbinform1 ~/usbinform | zenity --list --title="${disk}" --column="Size" --column="Size KiB" --column="Description" --width=800 --height=650 --ok-label="Save" --cancel-label="OK" --text="Drive ${disk} Storage Summary\n1KB=1000 bytes, 1KiB=1024 bytes"

#Test for cancellation
if [[ ${?} != 0 ]]
then
    rm ~/usbinform
    rm ~/usbinform1
    rm ~/usbinform2
       exit 0
fi

#Ask where to save our file
zNewData=$(paste -d'\t' ~/usbinform2 ~/usbinform1 ~/usbinform)
zSavePath=$(echo -n "$(zenity --file-selection --save --confirm-overwrite --filename="USBdrive_summary.txt" --title="Save USB drive info")")

#Test for cancellation
if [[ ${?} != 0 ]]
then
    rm ~/usbinform
    rm ~/usbinform1
    rm ~/usbinform2
       exit 0
fi

#save
echo -n "$zNewData" > "$zSavePath"

# Remove temp files
rm ~/usbinform
rm ~/usbinform1
rm ~/usbinform2
exit
Edit: lol a small error fixed not 38 it's 37   ::)

68
Zenity & Yad / Re: checksums
« on: July 24, 2015, 06:26:24 PM »
Thank you fellows  :)

69
VSIDO Changes / Re: Yad startup script for ceni
« on: July 15, 2015, 03:59:30 AM »
Had some spare time to play with yad.  :)
Just some cosmetic changes to the VSIDO Message Center. Tried text-info dialogue but it won't process html so I just added some markup to the existing.

Code: [Select]
#! /bin/bash

# Greeting window
yad --title="VSIDO Message Center" --center --width=420 --image=vsido-start \
--button=$"Run Ceni                                  :0" \
--button=$"Close                                     :1" \
--text=$"\t\t\t<b><big>Welcome to VSIDO</big></b>\n\n\tDue to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates\n
\t<tt>It is recommended that you run <b>Ceni</b> or <b>WICD</b> to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options by clicking on the WICD icon in the system-tray above right</tt>\n
\tSimply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established
${custom_text}" \


if [ $? -eq 0 ] ; then
xfce4-terminal -e ceni

else
 exit 0

fi

By the way, this is a way to display Time and date with yad:
Code: [Select]
while true; do echo "$(echo "Time               Date" | sed 's/^/#/g')\n" "$(date '+%T       %D')"; sleep 1; done | yad --progress --title="Time" --cancel-label="close"
:D

70
Zenity & Yad / checksums
« on: May 18, 2015, 02:50:51 PM »
This is a script I made for the thunar custom action.
Depends on zenity and pv.
Calculates md5, sha1 and sha2 sums.
I use pv to show progress with zenity --progress dialogue.
Make sure to install pv
Code: [Select]
apt-get install zenity pv
-save the script as checksum
-make executable
-copy the file to /usr/local/bin

Code: [Select]
#!/bin/bash
# Purpose:  Thunar Custom Action. Calculates hashes.
# Usage:     /usr/local/bin/checksum %f
# Author:    Misko_2083
# Date:       May, 2015
# Version:    1.2
# Licence GPLv2
# Dependancy: zenity, pv

file="$@"

# Check that the user didn't select directory
if [ -d "$file" ]; then
zenity --error --text="'$file' is a directory. Checksum cannot handle directories."
exit
fi

MD5=(`echo "" | awk '{print "TRUE","MD5", $0}'`)
SHA1=(`echo "" | awk '{print "FALSE","SHA-1", $0}'`)
SHA224=(`echo "" | awk '{print "FALSE","SHA-224", $0}'`)
SHA256=(`echo "" | awk '{print "FALSE","SHA-256", $0}'`)
SHA384=(`echo "" | awk '{print "FALSE","SHA-384", $0}'`)
SHA512=(`echo "" | awk '{print "FALSE","SHA-512", $0}'`)

selection=$(zenity --list --radiolist --height=300 --title="Checksum" --text="File:  <b>${file##*/}</b>\nPick the hash function." --column="Pick" --column="Hash" "${MD5[@]}" "${SHA1[@]}" "${SHA224[@]}" "${SHA256[@]}" "${SHA384[@]}" "${SHA512[@]}")

# If Cancel is clicked then exit
if [ $? != "0" ]; then
    exit 0
fi

# Creates a temp file to store the hash sum
sum_temp=$(mktemp /tmp/sum.XXXXXXXX)


# If there is a pipe file removes it
if [[ -p /tmp/checksum_fifo ]]; then
rm /tmp/checksum_fifo || `zenity --error --text="<tt>Could not remove <i>/tmp/checksum_fifo</i>\nCheck the file permissions.</tt>" && exit 1`
fi

# Create a named pipe for storing percentage from pv
mkfifo --mode=0666 /tmp/checksum_fifo

echo $selection | grep "MD5" > /dev/null
if [ $? = 0 ];then
   # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | md5sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating MD5 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="MD5sum" --text="MD5sum : $sum\nFile :          ${file##*/}" --no-wrap
   
    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-1" > /dev/null
if [ $? = 0 ];then
    # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha1sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-1 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-1" --text="SHA-1: $sum\nFile :    ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-224" > /dev/null
if [ $? = 0 ];then
   # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha224sum  2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-224 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-224" --text="SHA-224 : $sum\nFile :         ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-256" > /dev/null
if [ $? = 0 ];then
    # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha256sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-256 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-256" --text="SHA-256 : $sum\nFile :          ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-384" > /dev/null
if [ $? = 0 ];then
    # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha384sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-384 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-384" --text="SHA-384 : $sum\nFile :         ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-512" > /dev/null
if [ $? = 0 ];then
    # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha512sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-512 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-512" --text="SHA-512 : $sum\nFile :           ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

This is how to setup a Thunar Custom Action:
Name: Checksum
Description: Computes checksum.
Command: /usr/local/bin/checksum %f
Pattern: *
Appearance: Check all the boxes except Directories

After setting this up, you can  right click on an *.iso file and test this.

If you don't want to install thunar file manager, you can use a version with file-selection dialogue:

Code: [Select]
#!/bin/bash
# Purpose:  Calculates hashes.
# Usage:     /usr/local/bin/checksum
# Author:    Misko_2083
# Date:       May, 2015
# Version:    1.2
# Licence GPLv2
# Dependancy: zenity, pv

#Select the file
file="$(zenity --file-selection --title=Select file)"

# Check that the user didn't select directory
if [ -d "$file" ]; then
zenity --error --text="'$file' is a directory. Checksum cannot handle directories."
exit
fi

MD5=(`echo "" | awk '{print "TRUE","MD5", $0}'`)
SHA1=(`echo "" | awk '{print "FALSE","SHA-1", $0}'`)
SHA224=(`echo "" | awk '{print "FALSE","SHA-224", $0}'`)
SHA256=(`echo "" | awk '{print "FALSE","SHA-256", $0}'`)
SHA384=(`echo "" | awk '{print "FALSE","SHA-384", $0}'`)
SHA512=(`echo "" | awk '{print "FALSE","SHA-512", $0}'`)

selection=$(zenity --list --radiolist --height=300 --title="Checksum" --text="File:  <b>${file##*/}</b>\nPick the hash function." --column="Pick" --column="Hash" "${MD5[@]}" "${SHA1[@]}" "${SHA224[@]}" "${SHA256[@]}" "${SHA384[@]}" "${SHA512[@]}")

# If Cancel is clicked then exit
if [ $? != "0" ]; then
    exit 0
fi

# Creates a temp file to store the hash sum
sum_temp=$(mktemp /tmp/sum.XXXXXXXX)


# If there is a pipe file removes it
if [[ -p /tmp/checksum_fifo ]]; then
rm /tmp/checksum_fifo || `zenity --error --text="<tt>Could not remove <i>/tmp/checksum_fifo</i>\nCheck the file permissions.</tt>" && exit 1`
fi

# Create a named pipe for storing percentage from pv
mkfifo --mode=0666 /tmp/checksum_fifo

echo $selection | grep "MD5" > /dev/null
if [ $? = 0 ];then
   # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | md5sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating MD5 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="MD5sum" --text="MD5sum : $sum\nFile :          ${file##*/}" --no-wrap
   
    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-1" > /dev/null
if [ $? = 0 ];then
    # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha1sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-1 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-1" --text="SHA-1: $sum\nFile :    ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-224" > /dev/null
if [ $? = 0 ];then
   # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha224sum  2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-224 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-224" --text="SHA-224 : $sum\nFile :         ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-256" > /dev/null
if [ $? = 0 ];then
    # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha256sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-256 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-256" --text="SHA-256 : $sum\nFile :          ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-384" > /dev/null
if [ $? = 0 ];then
    # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha384sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-384 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-384" --text="SHA-384 : $sum\nFile :         ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi

echo $selection | grep "SHA-512" > /dev/null
if [ $? = 0 ];then
    # Creates a subshell and sends progress to the named pipe
   ( pv -n "$file" | sha512sum 2>&1 | tee >(cut -d ' ' -f1 > $sum_temp) ) 2>/tmp/checksum_fifo &
PVPID=$!

    # Creates a subshell and reads progress from the named pipe
   ( zenity --progress --title="MD5sum" --text="Calculating SHA-512 for:\n${file##*/}" --percentage=0 --auto-close </tmp/checksum_fifo;

# If Cancel is clicked
if [ $? = 1 ];then
# Kill the sum process
kill $PVPID;
# Removes the tmp file and the pipe
rm $sum_temp;
rm /tmp/checksum_fifo
# Kill off this app
killall checksum;

fi;
# Removes the pipe file
rm /tmp/checksum_fifo ) &
ZENPID=$!

   #Wait until progressbar process finishes
   wait $ZENPID
   
    #Displays results
    sum=`cat $sum_temp`
    zenity --info --title="SHA-512" --text="SHA-512 : $sum\nFile :           ${file##*/}" --no-wrap

    #Cleanup
    rm $sum_temp
    exit 0
fi
Cheers  :)

Pages: 1 ... 3 4 [5]