You are not logged in.

#1 2017-10-14 21:02:08

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 777

Tint2 Executors and Buttons.

I have been building a number of tint2 executors. I thought it might be nice to assemble them in one place.

tint2 config

First is the tint2 config. It will show how I define each executor. I will only post the relevant portions from the tint2 config.For this particular tint2 bar, I am not using a taskbar on it.

#-------------------------------------
# Panel
panel_items = E:E:E:E:F:S:CP
panel_size = 100% 48
panel_margin = 0 1
panel_padding = 6 0 0
panel_background_id = 1
wm_menu = 1
panel_dock = 0
panel_position = top center horizontal
panel_layer = bottom
panel_monitor = all
panel_shrink = 0
autohide = 0
autohide_show_timeout = 0.3
autohide_hide_timeout = 1.5
autohide_height = 6
strut_policy = follow_size
panel_window_name = tint2
disable_transparency = 0
mouse_effects = 1
font_shadow = 0
mouse_hover_icon_asb = 20 0 20
mouse_pressed_icon_asb = 100 0 0

#-------------------------------------
# Separator 1
separator = new
separator_background_id = 0
separator_color = #5d8185 60
separator_style = line
separator_size = 2
separator_padding = 4 8

#-------------------------------------
# Separator 2
separator = new
separator_background_id = 0
separator_color = #5d8185 60
separator_style = line
separator_size = 2
separator_padding = 4 8

#-------------------------------------
# Separator 3
separator = new
separator_background_id = 0
separator_color = #5d8185 60
separator_style = line
separator_size = 2
separator_padding = 4 8

#-------------------------------------
# Separator 4
separator = new
separator_background_id = 0
separator_color = #5d8185 60
separator_style = line
separator_size = 2
separator_padding = 4 8

#-------------------------------------
# Separator 5
separator = new
separator_background_id = 0
separator_color = #5d8185 60
separator_style = line
separator_size = 2
separator_padding = 4 8

#-------------------------------------
# Separator 5
separator = new
separator_background_id = 0
separator_color = #5d8185 60
separator_style = line
separator_size = 2
separator_padding = 4 8

#-------------------------------------
# Executor 1
execp = new
execp_command = hostname
execp_interval = 0
execp_has_icon = 0
execp_cache_icon = 1
execp_continuous = 0
execp_markup = 1
execp_tooltip = Left click for hardinfo
execp_lclick_command = hardinfo
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = Droid Sans Fallback 12
execp_font_color = #00ffff 100
execp_padding = 0 0
execp_background_id = 0
execp_centered = 0
execp_icon_w = 0
execp_icon_h = 0

#-------------------------------------
# Executor 2
execp = new
execp_command = /home/tknomanzr/bin/python/uptime.py
execp_interval = 1
execp_has_icon = 0
execp_cache_icon = 1
execp_continuous = 1
execp_markup = 1
execp_tooltip = Total Uptime. Left click for htop
execp_lclick_command = x-terminal-emulator --command=htop; exit
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = Droid Sans Fallback 12
execp_font_color = #00ffff 100
execp_padding = 2 2
execp_background_id = 0
execp_centered = 0
execp_icon_w = 0
execp_icon_h = 0

#-------------------------------------
# Executor 3
execp = new
execp_command = /home/tknomanzr/bin/python/cpu.py
execp_interval = 1
execp_has_icon = 0
execp_cache_icon = 1
execp_continuous = 1
execp_markup = 1
execp_tooltip = Left click for per cpu info
execp_lclick_command = /home/tknomanzr/bin/python/per_cpu.py
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = Droid Sans Fallback 12
execp_font_color = #00ffff 100
execp_padding = 2 2
execp_background_id = 0
execp_centered = 0
execp_icon_w = 0
execp_icon_h = 0

#-------------------------------------
# Executor 4
execp = new
execp_command = /home/tknomanzr/bin/python/bitcoin/show_bitcoin
execp_interval = 60*60
execp_has_icon = 0
execp_cache_icon = 1
execp_continuous = 1
execp_markup = 0
execp_tooltip = Left click for details and historical prices
execp_lclick_command = /home/tknomanzr/bin/python/bitcoin/show_bitcoin_detail.py
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = Droid Sans Fallback 12
execp_font_color = #00ffff 100
execp_padding = 2 2
execp_background_id = 0
execp_centered = 0
execp_icon_w = 36
execp_icon_h = 36

uptime.py
This script shows the uptime for the system. It has no additional dependencies.

#!/usr/bin/env python

from datetime import timedelta

with open('/proc/uptime', 'r') as f:
    uptime_seconds = float(f.readline().split()[0])
    uptime_seconds = int(uptime_seconds)
    uptime_string = str(timedelta(seconds = uptime_seconds))

print("Uptime: " + uptime_string)

Offline

#2 2017-10-14 21:03:25

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 777

Re: Tint2 Executors and Buttons.

cpu.py
The next script is the cpu.py script. It's job is to show overall cpu useage on the tint2 bar. It depends on psutil. This can be obtained in Debian with the command:

sudo apt install python-psutil

The script:

!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  cpu.py
#  
#  Copyright 2017 William Bradley <tknomanzr@testbed>
#  
#  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 psutil

result = psutil.cpu_percent(interval=1)
print ("cpu%: " + str(result))

per_cpu.py

Next is a small pygtk app that shows the cpu usage per logical core. It is possible to modify the script to show only physical cores. I might implement an arg parser for this script at some point, so that we could show logical or physical cores. I plan to implement more details from psutil into this script eventually. At present it is a small example of implementing a pygtk script with asynchronous threading. This script depends on python-psutil, pygtk, gtk and gobject. pygtk can be obtained via the command:

sudo apt install python-gtk2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# per_ cpu.py
#  
#  Copyright 2017 William Bradley <tknomanzr@testbed>
#  
#  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 psutil
import sys
import pygtk, gobject
pygtk.require('2.0')
import gtk
from threading import Thread
class Per_Cpu:
	global labels 
	labels = []
	global vbox 
	vbox = gtk.VBox()
	
	def show_per_cpu(self):
		result = psutil.cpu_percent(interval=None, percpu=True)
		return result
		
	def destroy(self, widget, data=None):
		gtk.main_quit()
		return
	
	def threaded(self):
		thread = Thread(target=self.updateValues)
		thread.start()
		return True

	def updateValues(self):
		for label in labels:
				label.destroy()
		try:
			self.button
			self.button.destroy()
		except:
			pass
		result = self.show_per_cpu()
		# Add labels for each value in the result list.
		for i in result:
			msg = '<big>cpu ' + str(result.index(i)) + ': ' + str(i) + '</big>'
			self.label = gtk.Label()
			self.label.set_markup(msg)
			labels.append(self.label)
			vbox.pack_start(self.label, False)
		self.button = gtk.Button("Exit")
		self.button.connect("clicked", self.destroy, None)
		self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
		# This packs the button into the window (a GTK container).
		vbox.pack_start(self.button, False)
		self.window.show_all()
		return
		
	def __init__(self):
		# create a new window
		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.window.connect("destroy", self.destroy)
		self.window.set_title("Per CPU Usage")
		self.window.set_decorated(False)
		self.window.set_keep_above(True)
		self.window.move(200, 48)
		# Sets the border width of the window.
		self.window.set_border_width(2)
		# Create a widget container
		self.window.add(vbox)
		num_cpus = psutil.cpu_count(logical = True)
		msg = "<big>Showing results for " + str(num_cpus) + " logical cpu cores.</big>"
		self.label = gtk.Label()
		self.label.set_markup(msg)
		vbox.pack_start(self.label, False)
		# Add a button to exit the window
		self.updateValues()
		self.window.show_all()
		
	def main(self):
		# Ensure that only one instance of the program runs.
		try:
			import socket
			s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
			## Create an abstract socket, by prefixing it with null. 
			s.bind( '\0postconnect_gateway_notify_lock') 
		except socket.error as e:
			error_code = e.args[0]
			error_string = e.args[1]
			print "Process already running (%d:%s ). Exiting" % ( error_code, error_string) 
			sys.exit (0) 
		gobject.timeout_add_seconds(1, self.threaded)
		gobject.threads_init()
		gtk.main()
		
if __name__ == "__main__":
	win = Per_Cpu()
	win.main()

Offline

#3 2017-10-14 21:13:00

Dobbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 1,530
Website

Re: Tint2 Executors and Buttons.

I'm liking where this is heading.  Thanks for the information so far.  If you have a config for a weather executor, I wouldn't complain if you added it here smile


I like my Metal like my coffee.......Black!

Get my dots from here

Offline

#4 2017-10-14 21:16:56

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 777

Re: Tint2 Executors and Buttons.

show_bitcoin.py
This is a modification of the show_bitcoin script I used for conky. One the tint2 bar, it only shows the relative value of any bitcoin stored in an electrum wallet. This script depends on electrum and electrum must be properly setup. This script uses the unicode value for Bitcoin. If it does not show properly, it is likely a font issue.

#! /usr/bin/python
# A simple utility that will calculate bitcoin balance from an electrum wallet.
# Requires: electrum
# Assumes: you currently have bitcoin stored in an electrum wallet.
# Author: William Bradley
# BunsenLabs Forum Handle: tknomanzr
# License: wtfpl. Use this script however you see fit.

import json, urllib2, subprocess
import sys
reload(sys)
sys.setdefaultencoding('UTF8')

url = 'https://coinbase.com/api/v1/prices/historical'
# Get current bitcoin price
price =  urllib2.urlopen(url)
price_data = price.read(34)
price_data = price_data[26:-2]
price_data = float(price_data)
# Get balance from wallet.
# It comes in as a json object that needs to be converted.
balance = json.loads(subprocess.check_output(["electrum","getbalance"]))
current_balance = balance['confirmed']
current_balance = float(current_balance)
# Get approximate value of bitcoin in wallet.
value = price_data * current_balance
bitcoin = u'\u0243'
print (bitcoin + ': $' + str(round(value,2))

Finally, I wanted to show details as a historical price graph for the past thirty days. This is a heavy script with several dependencies. The script depends on:

  • gdax

  • pandas

  • matplotlib

I obtained these three dependencies via pip install. However, pandas can be installed via

sudo apt install python-pandas

Similarly, matplotlib can be installed via the command:

sudo apt install python-matplotlib

Debian does not have gdax in its repositories. It will have to be installed via pip install. Gdax is a pythonic bitcoin trading api. However, we only care about the function get_historic_rates, which requires no api keys or sign ins.
The script:

#! /usr/bin/python
# A simple utility that will calculate bitcoin balance from an electrum wallet.
# Requires: gdax, pandas, matplotlib
# Assumes: you currently have bitcoin stored in an electrum wallet.
# Author: William Bradley
# BunsenLabs Forum Handle: tknomanzr
# License: GPL3.0.

import gdax
import pandas as pd
import matplotlib.pyplot as plt 
plt.style.use('dark_background')
import datetime
import subprocess
import os, fcntl
def run_once():
    global fh
    fh=open(os.path.realpath(__file__),'r')
    try:
        fcntl.flock(fh,fcntl.LOCK_EX|fcntl.LOCK_NB)
    except:
        os._exit(0)
    return

if __name__ == "__main__":
	run_once()
	# Get historical bitcoin price information from gdax     
	client = gdax.PublicClient()
	rates = client.get_product_historic_rates('BTC-USD', granularity=60*60*24)
	# Modify the dates from ISO 8601 to human readable.
	dates = [datetime.date.fromtimestamp(element[0]) for element in rates]
	# Create the pandas plot. 
	df = pd.DataFrame(rates, columns = ['date', 'low', 'high', 'open', 'close', 'volume'])
	df['date'] = [datetime.date.fromtimestamp(element[0]) for element in rates]
	df = df.head(30)
	df = df.sort_values('date', ascending = True)
	df.plot('date', 'close', kind='line', use_index=True, title='Bitcoin closing prices by date', rot=90, grid=True, figsize=[6,9])
	plt.show()

Finally, a screenshot to show it all in action up to this point:
Screenshot_2017-10-14_15-27-37.th.png

Stay tuned. There will  be more to come. Also, please feel free to post your own tint2 executor scripts.

Offline

#5 2017-10-14 21:27:57

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 777

Re: Tint2 Executors and Buttons.

@dobbie03. Thanks. That will be my next script wink I will look into whether there is an api I can use.

Offline

#6 2017-10-14 21:44:30

Dobbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 1,530
Website

Re: Tint2 Executors and Buttons.

Awesome!  Thank you.


I like my Metal like my coffee.......Black!

Get my dots from here

Offline

#7 2017-10-15 02:50:17

Dobbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 1,530
Website

Re: Tint2 Executors and Buttons.

Thanks to the awesome Addy I have a weather display

 #!/bin/bash

# I take this script from Anachron's i3blocks
# I only slightly modify this script to add an option to show icon, useful for my tint2 executor
# 'weather -i' = with icon, 'weather' = text only
# Cheers!
# Addy

# Open Weather Map API code, register to http://openweathermap.org to get one ;)
API_KEY="your API here"

# Check on http://openweathermap.org/find
CITY_ID="your city id here"

URGENT_LOWER=0
URGENT_HIGHER=30

ICON_SUNNY="  Clear"
ICON_CLOUDY="  Cloudy"
ICON_RAINY="  Rainy"
ICON_STORM="  Storm"
ICON_SNOW="  Snow"
ICON_FOG="  Fog"
ICON_MISC=" "

TEXT_SUNNY="Clear"
TEXT_CLOUDY="Cloudy"
TEXT_RAINY="Rainy"
TEXT_STORM="Storm"
TEXT_SNOW="Snow"
TEXT_FOG="Fog"

SYMBOL_CELSIUS="˚C"

WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"

WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[a-Z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')

if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Rain* ]] || [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Fog* ]] || [[ "${WEATHER_MAIN}" = *Mist* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
else
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_MISC} ${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi	
fi

if [[ "${WEATHER_TEMP}" -lt "${URGENT_LOWER}" ]] || [[ "${WEATHER_TEMP}" -gt "${URGENT_HIGHER}" ]]; then
  exit 33
fi

I have this as a script saved in ~/.bin/weather.  Works a treat


I like my Metal like my coffee.......Black!

Get my dots from here

Offline

#8 2017-10-15 07:51:20

ohnonot
...again
Registered: 2015-09-29
Posts: 2,190
Website

Re: Tint2 Executors and Buttons.

^ i have not a single font in my collection that would display these icons right.
how do you do it?

Offline

#9 2017-10-15 11:52:26

Addy
Member
From: Most populated island on Earth
Registered: 2017-07-14
Posts: 63
Website

Re: Tint2 Executors and Buttons.

Dobbie03 wrote:

Thanks to the awesome Addy I have a weather display

 #!/bin/bash

# I take this script from Anachron's i3blocks
# I only slightly modify this script to add an option to show icon, useful for my tint2 executor
# 'weather -i' = with icon, 'weather' = text only
# Cheers!
# Addy

# Open Weather Map API code, register to http://openweathermap.org to get one ;)
API_KEY="your API here"

# Check on http://openweathermap.org/find
CITY_ID="your city id here"

URGENT_LOWER=0
URGENT_HIGHER=30

ICON_SUNNY="  Clear"
ICON_CLOUDY="  Cloudy"
ICON_RAINY="  Rainy"
ICON_STORM="  Storm"
ICON_SNOW="  Snow"
ICON_FOG="  Fog"
ICON_MISC=" "

TEXT_SUNNY="Clear"
TEXT_CLOUDY="Cloudy"
TEXT_RAINY="Rainy"
TEXT_STORM="Storm"
TEXT_SNOW="Snow"
TEXT_FOG="Fog"

SYMBOL_CELSIUS="˚C"

WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"

WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[a-Z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')

if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Rain* ]] || [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Fog* ]] || [[ "${WEATHER_MAIN}" = *Mist* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
else
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_MISC} ${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi	
fi

if [[ "${WEATHER_TEMP}" -lt "${URGENT_LOWER}" ]] || [[ "${WEATHER_TEMP}" -gt "${URGENT_HIGHER}" ]]; then
  exit 33
fi

I have this as a script saved in ~/.bin/weather.  Works a treat

Thanks for posting it here! I feel appreciated.
And big credits to Anachron for his i3blocks module.

ohnonot wrote:

^ i have not a single font in my collection that would display these icons right.
how do you do it?

It needs awesome font wink


If it ain't broke, then tweak it until it breaks.

Offline

#10 2017-10-16 04:33:46

Dobbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 1,530
Website

Re: Tint2 Executors and Buttons.

Thanks for answering in my absence Addy.


I like my Metal like my coffee.......Black!

Get my dots from here

Offline

#11 2017-10-19 23:48:19

SBruleMD
Member
Registered: 2017-02-12
Posts: 9

Re: Tint2 Executors and Buttons.

Something I am working on for moc:

i88GxlX.gif

Inspired by ohnonot's mpi-panel, which I've been using for months.

Offline

#12 2017-10-20 01:17:05

Addy
Member
From: Most populated island on Earth
Registered: 2017-07-14
Posts: 63
Website

Re: Tint2 Executors and Buttons.

SBruleMD wrote:

Something I am working on for moc:

https://i.imgur.com/i88GxlX.gif

Inspired by ohnonot's mpi-panel, which I've been using for months.

Wow, it has a running text?? yikes
It's cool


If it ain't broke, then tweak it until it breaks.

Offline

#13 2017-10-20 02:38:05

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 777

Re: Tint2 Executors and Buttons.

^ Nice!

Offline

#14 2017-10-21 09:25:34

Steve
Member
Registered: 2017-01-03
Posts: 568

Re: Tint2 Executors and Buttons.

Just wanted to add a nice little yad bash script i found that can be incorporated into a tint2 button.

http://smokey01.com/yad/

Multi progress bars options
    Here is an excellent example of multiple progress bars. It will only show the drives that are
    currently mounted.

    eval exec yad --title="xdf" --image=drive-harddisk --text="Disk\ usage:" --buttons-layout=end --width=650 --multi-progress \
    $(df -hT $1 | tail -n +2 | awk '{printf "--bar=\"<b>%s</b> (%s - %s) [%s/%s]\" %s ", $7, $1, $2, $4, $3, $6}')

I call it mounted.sh

#!/bin/sh
eval exec yad --title="xdf" --image=drive-harddisk --text="Disk\ usage:" --buttons-layout=end --width=650 --multi-progress \
$(df -hT $1 | tail -n +2 | awk '{printf "--bar=\"<b>%s</b> (%s - %s) [%s/%s]\" %s ", $7, $1, $2, $4, $3, $6}')

Tint2 button used... http://www.iconsdb.com/gray-icons/hdd-icon.html

Tint2 button config ...

#-------------------------------------
# Button 1
button = new
button_icon = /home/sc/Pictures/mounted-buttons/hdd-24.png
button_text = 
button_lclick_command = mounted.sh
button_rclick_command = 
button_mclick_command = 
button_uwheel_command = 
button_dwheel_command = 
button_font = Sans 10
button_font_color = #ffffff 100
button_padding = 8 0
button_background_id = 0
button_centered = 0
button_max_icon_size = 22

Scrots...

Screenshot_2017-10-21_20-22-29.png
Screenshot_2017-10-21_20-23-12.md.png

Offline

#15 2017-10-21 11:20:21

Steve
Member
Registered: 2017-01-03
Posts: 568

Re: Tint2 Executors and Buttons.

Yad + Tint2 button password generator from bash script.

passgen.sh

#!/bin/sh

date +%s | sha256sum | base64 | head -c 32 ; echo

yad command...

passgen.sh | yad --title "passgen" --text-info --width 53

Button = http://www.iconsdb.com/gray-icons/key-3-icon.html

Tint2 config...

#-------------------------------------
# Button 1
button = new
button_icon = /home/sc/Pictures/passgen-buttons/key1.png
button_text = 
button_lclick_command = passgen.sh | yad --title "passgen" --text-info --width 53
button_rclick_command = 
button_mclick_command = 
button_uwheel_command = 
button_dwheel_command = 
button_font_color = #ffffff 100
button_padding = 2 0
button_background_id = 0
button_centered = 0
button_max_icon_size = 22

Scrot...

Screenshot_2017-10-21_22-19-09.md.png

Offline

#16 2017-10-21 15:27:32

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 777

Re: Tint2 Executors and Buttons.

^ Both of these are sweet. Thanks for the contribution.

Offline

#17 2017-10-21 16:13:45

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 812

Re: Tint2 Executors and Buttons.

@Steve Those are really cool!

Just popped in my mind that probably damo's script regarding power consumption could be also used with yad and a button.

Offline

#18 2017-10-22 02:11:28

Steve
Member
Registered: 2017-01-03
Posts: 568

Re: Tint2 Executors and Buttons.

^^ cheers.

Got one more, this is for arch users to check updates but you could do similar for deb users as well.

Im using simple terminal here just because its simple  wink

#-------------------------------------
# Button 1
button = new
button_icon = /home/sc/Pictures/Update-buttons/archupdate.png
button_text = 
button_lclick_command = st -g 50x20 -f monospace -t pac-update -e sudo pacman -Syu
button_rclick_command = 
button_mclick_command = 
button_uwheel_command = 
button_dwheel_command = 
button_font_color = #ffffff 100
button_padding = 4 0
button_background_id = 0
button_centered = 0
button_max_icon_size = 22

Screenshot_2017-10-22_13-05-49.png

Offline

#19 2017-10-22 06:33:27

ohnonot
...again
Registered: 2015-09-29
Posts: 2,190
Website

Re: Tint2 Executors and Buttons.

Steve wrote:

Yad + Tint2 button password generator from bash script.

passgen.sh

#!/bin/sh

date +%s | sha256sum | base64 | head -c 32 ; echo
openssl rand -base64 32

maybe better?
;-)

or maybe even

openssl rand -base64 32 | xclip -selection clipboard

Last edited by ohnonot (2017-10-22 06:39:16)

Offline

#20 2017-10-22 10:14:11

Steve
Member
Registered: 2017-01-03
Posts: 568

Re: Tint2 Executors and Buttons.

ohnonot wrote:
Steve wrote:

Yad + Tint2 button password generator from bash script.

passgen.sh

#!/bin/sh

date +%s | sha256sum | base64 | head -c 32 ; echo

;-)

or maybe even

openssl rand -base64 32 | xclip -selection clipboard

You could do away with yad altogether with that one, a lot less clicks so that is a good one!

I needed to install xclip for that command though.

Last edited by Steve (2017-10-22 10:15:07)

Offline

#21 2017-10-23 00:32:03

SBruleMD
Member
Registered: 2017-02-12
Posts: 9

Re: Tint2 Executors and Buttons.

SBruleMD wrote:

Something I am working on for moc:

https://i.imgur.com/i88GxlX.gif

Inspired by ohnonot's mpi-panel, which I've been using for months.

I've posted my python script on gitlab for anyone interested. Going to play with it some more, but I've been using it as-is for the last three days.

I really like the look of the scrolling text on my thicc thin panel. Might do something with a scrolling ticker and twitter updates or sms alerts via KDE Connect on my desktop.

Offline

#22 2017-10-24 05:38:45

ohnonot
...again
Registered: 2015-09-29
Posts: 2,190
Website

Re: Tint2 Executors and Buttons.

^ i like it!
my original inspiration for the mpi script was to get the output on 2 or more lines, but i have long since given up on that (i still use the script though).
scrolling makes a lot of sense.

i was also planning to make support for different media players modular.
it's not much work, actually, but still not finished :-(

Offline

#23 2017-10-24 15:51:26

SBruleMD
Member
Registered: 2017-02-12
Posts: 9

Re: Tint2 Executors and Buttons.

ohnonot wrote:

i was also planning to make support for different media players modular.
it's not much work, actually, but still not finished :-(

Yeah, I had noticed that looking over your code you have placeholders for MPD and mplayer.  I know deadbeef and audacious can output the info easly too; Clementine looked a little more complicated. A little refactoring on mine, and they would integrate cleanly. MOC was my focus, since... thats what I use.

Offline

#24 2017-10-31 11:57:41

Steve
Member
Registered: 2017-01-03
Posts: 568

Re: Tint2 Executors and Buttons.

Got a question more reserved for openbsd users.

Ive created two buttons in tint2 using the following...

shutdown= doas halt -p
This shuts down the computer immediately. I would like a safer option in the button like a 2 step verification.

same with reboot = doas reboot

I cant seem to figure out how to implement a warning/hold message before the command executes.

Any ideas?

Last edited by Steve (2017-10-31 11:58:11)

Offline

#25 2017-10-31 13:19:06

Steve
Member
Registered: 2017-01-03
Posts: 568

Re: Tint2 Executors and Buttons.

^^ figured it out with some googlefu or startpagefu wink

reboot.sh

#!/bin/sh
echo "Would you like to 'reboot' [y/n]?"
read ans


if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
then
xterm -e doas reboot
fi


if [ $ans = n -o $ans = N -o $ans = no -o $ans = No -o $ans = NO ]
then
echo "rock on"
fi

shutdown.sh

shutdown.sh
#!/bin/sh
echo "Would you like to 'shutdown' [y/n]?"
read ans


if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
then
xterm -e doas halt -p
fi


if [ $ans = n -o $ans = N -o $ans = no -o $ans = No -o $ans = NO ]
then
echo "rock on"
fi

tint2 buttons, left click commands.

reboot =

xterm -geometry 65x15 -bg black -fg white -fa 'terminus' -fs 10 -e "ksh -c \"reboot.sh; exec ksh\""

shutdown=

xterm -geometry 65x15 -bg black -fg white -fa 'terminus' -fs 10 -e "ksh -c \"shutdown.sh; exec ksh\""

Not the best of options but it works.

Last edited by Steve (2017-10-31 13:20:01)

Offline

Board footer

Powered by FluxBB