Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge of bunsen-exit, bunsen-lock, bunsen-user-setup and bunsen-wmhacks.
- Loading branch information
0 parents
commit ba4d9d3
Showing
16 changed files
with
1,343 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
bunsen-utilities | ||
================ | ||
|
||
A collection of small scripts to provide various functions | ||
which might be useful to BunsenLinux users. | ||
bl-exit: Logout dialog box with various options. | ||
bl-lock: Script to lock the display. | ||
bl-user-setup: Script to install user config files in ~/ | ||
bl-aerosnap: Script to add aero style window snapping to Openbox. | ||
bl-hotcorners: Script to add hot corners to Openbox. | ||
|
||
Originally imported from cb-exit, cb-lock, cb-slim and cb-wmhacks, | ||
made for CrunchBang Linux and subsequently modified for BunsenLabs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/usr/bin/env python | ||
# bl-aerosnap: | ||
# A script for adding aero style window snapping to Openbox. | ||
# Repackaged for BunsenLabs by John Crawley. | ||
# Originally written for CrunchBang Linux <http://crunchbang.org/> | ||
# by Philip Newborough <corenominal@corenominal.org> | ||
# ---------------------------------------------------------------------- | ||
|
||
from subprocess import Popen, PIPE, STDOUT | ||
import sys, time, os, re | ||
|
||
history = '/tmp/bl-aerosnap-'+str(os.getuid()) | ||
windows = {} | ||
check_intervall = 0.2 | ||
|
||
p = Popen(['xdotool','getdisplaygeometry'], stdout=PIPE, stderr=STDOUT) | ||
Dimensions = p.communicate() | ||
Dimensions = Dimensions[0].replace('\n', '') | ||
Dimensions = Dimensions.split(' ') | ||
width = int(Dimensions[0]) | ||
height = int(Dimensions[1]) | ||
hw = width / 2 | ||
rt = width - 1 | ||
bt = height - 1 | ||
aeroLcommand="wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -b remove,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,"+str(hw)+",-1" | ||
aeroRcommand="wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -b remove,maximized_horz && wmctrl -r :ACTIVE: -e 0,"+str(hw)+",0,"+str(hw)+",-1" | ||
|
||
|
||
if os.path.exists(history) == False: | ||
f = open(history,'w') | ||
f.close() | ||
|
||
def print_usage(): | ||
print "bl-aerosnap: usage:" | ||
print " --help show this message and exit" | ||
print " --aero-left attempt to snap active window to left of screen" | ||
print " --aero-right attempt to snap active window to right of screen" | ||
print "" | ||
exit() | ||
|
||
def is_root_window(): | ||
p = Popen(['xdotool', 'getactivewindow'], stdout=PIPE, stderr=STDOUT) | ||
ID = p.communicate() | ||
if len(ID[0]) > 50: | ||
return True | ||
|
||
def window_id(): | ||
p = Popen(['xdotool', 'getactivewindow'], stdout=PIPE) | ||
ID = p.communicate() | ||
ID = int(ID[0]) | ||
p = Popen(['xdotool', 'getwindowpid', str(ID)], stdout=PIPE) | ||
PID = p.communicate() | ||
PID = int(PID[0]) | ||
return str(ID)+'-'+str(PID) | ||
|
||
def window_lookup(): | ||
ID = window_id() | ||
windows = history_load() | ||
if windows.has_key(ID): | ||
return True | ||
|
||
def window_geometry(ID): | ||
ID = ID.split('-') | ||
p = Popen(['xdotool', 'getwindowgeometry', ID[0]], stdout=PIPE) | ||
p = p.communicate() | ||
Pos = re.search(r'\d+,\d+', p[0]) | ||
Size = re.search(r'\d+x\d+', p[0]) | ||
if Pos and Size: | ||
Pos = Pos.group().split(',') | ||
Size = Size.group().split('x') | ||
return Pos[0]+'|'+Pos[1]+'|'+Size[0]+'|'+Size[1] | ||
|
||
def window_store(): | ||
ID = window_id() | ||
windows[ID] = window_geometry(ID) | ||
s = ID +'|'+window_geometry(ID)+'\n' | ||
f = open(history,'a') | ||
f.write(s) | ||
f.close() | ||
|
||
def window_restore(width): | ||
ID = window_id() | ||
G = windows[ID].split('|') | ||
command = 'wmctrl -r :ACTIVE: -b remove,maximized_vert && ' | ||
#FIXME: adjust horizontal placement, not sure where this discrepancy comes from? | ||
AdjustT = int(G[1]) - 40 | ||
command += 'wmctrl -r :ACTIVE: -e 0,'+G[0]+','+str(AdjustT)+','+G[2]+','+G[3] | ||
del windows[ID] | ||
if len(windows) == 0: | ||
o = '' | ||
else: | ||
for key in windows: | ||
h = windows[key].split('|') | ||
o = key+'|'+h[0]+'|'+h[1]+'|'+h[2]+'|'+h[3]+'\n' | ||
f = open(history,'w') | ||
f.write(o) | ||
f.close() | ||
os.system(command) | ||
|
||
def history_load(): | ||
f = open(history,'r') | ||
i = 0 | ||
for line in f: | ||
h = line.split('|') | ||
h[4] = h[4].replace('\n', '') | ||
windows[h[0]] = h[1]+'|'+h[2]+'|'+h[3]+'|'+h[4] | ||
f.close() | ||
return windows | ||
|
||
if len(sys.argv) < 2 or sys.argv[1] == "--help": | ||
print_usage() | ||
|
||
elif sys.argv[1] == "--left": | ||
if is_root_window != True: | ||
if window_lookup(): | ||
window_restore(width) | ||
else: | ||
window_store() | ||
os.system(aeroLcommand) | ||
|
||
elif sys.argv[1] == "--right": | ||
if is_root_window != True: | ||
if window_lookup(): | ||
window_restore(width) | ||
else: | ||
window_store() | ||
os.system(aeroRcommand) | ||
|
||
else: | ||
print_usage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/usr/bin/python2 | ||
|
||
import pygtk | ||
pygtk.require('2.0') | ||
import gtk | ||
import os | ||
import getpass | ||
|
||
class bl_exit: | ||
def disable_buttons(self): | ||
self.cancel.set_sensitive(False) | ||
self.logout.set_sensitive(False) | ||
self.suspend.set_sensitive(False) | ||
self.reboot.set_sensitive(False) | ||
self.shutdown.set_sensitive(False) | ||
|
||
def cancel_action(self,btn): | ||
self.disable_buttons() | ||
gtk.main_quit() | ||
|
||
def logout_action(self,btn): | ||
self.disable_buttons() | ||
self.status.set_label("Exiting Openbox, please standby...") | ||
os.system("openbox --exit") | ||
|
||
def suspend_action(self,btn): | ||
self.disable_buttons() | ||
self.status.set_label("Suspending, please standby...") | ||
os.system("bl-lock") | ||
os.system("systemctl suspend") | ||
gtk.main_quit() | ||
|
||
def reboot_action(self,btn): | ||
self.disable_buttons() | ||
self.status.set_label("Rebooting, please standby...") | ||
os.system("systemctl reboot") | ||
|
||
def shutdown_action(self,btn): | ||
self.disable_buttons() | ||
self.status.set_label("Shutting down, please standby...") | ||
os.system("systemctl poweroff") | ||
|
||
def create_window(self): | ||
self.window = gtk.Window() | ||
title = "Log out " + getpass.getuser() + "? Choose an option:" | ||
self.window.set_title(title) | ||
self.window.set_border_width(5) | ||
self.window.set_size_request(500, 80) | ||
self.window.set_resizable(False) | ||
self.window.set_keep_above(True) | ||
self.window.stick | ||
self.window.set_position(1) | ||
self.window.connect("delete_event", gtk.main_quit) | ||
windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU) | ||
self.window.set_icon(windowicon) | ||
|
||
|
||
#Create HBox for buttons | ||
self.button_box = gtk.HBox() | ||
self.button_box.show() | ||
|
||
#Cancel button | ||
self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL) | ||
self.cancel.set_border_width(4) | ||
self.cancel.connect("clicked", self.cancel_action) | ||
self.button_box.pack_start(self.cancel) | ||
self.cancel.show() | ||
|
||
#Cancel key (Escape) | ||
accelgroup = gtk.AccelGroup() | ||
key, mod = gtk.accelerator_parse('Escape') | ||
accelgroup.connect_group(key, mod, gtk.ACCEL_VISIBLE, gtk.main_quit) | ||
self.window.add_accel_group(accelgroup) | ||
|
||
#Logout button | ||
self.logout = gtk.Button("_Log out") | ||
self.logout.set_border_width(4) | ||
self.logout.connect("clicked", self.logout_action) | ||
self.button_box.pack_start(self.logout) | ||
self.logout.show() | ||
|
||
#Suspend button | ||
self.suspend = gtk.Button("_Suspend") | ||
self.suspend.set_border_width(4) | ||
self.suspend.connect("clicked", self.suspend_action) | ||
self.button_box.pack_start(self.suspend) | ||
self.suspend.show() | ||
|
||
#Reboot button | ||
self.reboot = gtk.Button("_Reboot") | ||
self.reboot.set_border_width(4) | ||
self.reboot.connect("clicked", self.reboot_action) | ||
self.button_box.pack_start(self.reboot) | ||
self.reboot.show() | ||
|
||
#Shutdown button | ||
self.shutdown = gtk.Button("_Power off") | ||
self.shutdown.set_border_width(4) | ||
self.shutdown.connect("clicked", self.shutdown_action) | ||
self.button_box.pack_start(self.shutdown) | ||
self.shutdown.show() | ||
|
||
#Create HBox for status label | ||
self.label_box = gtk.HBox() | ||
self.label_box.show() | ||
self.status = gtk.Label() | ||
self.status.show() | ||
self.label_box.pack_start(self.status) | ||
|
||
#Create VBox and pack the above HBox's | ||
self.vbox = gtk.VBox() | ||
self.vbox.pack_start(self.button_box) | ||
self.vbox.pack_start(self.label_box) | ||
self.vbox.show() | ||
|
||
self.window.add(self.vbox) | ||
self.window.show() | ||
|
||
def __init__(self): | ||
self.create_window() | ||
|
||
|
||
def main(): | ||
gtk.main() | ||
|
||
if __name__ == "__main__": | ||
go = bl_exit() | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/usr/bin/env python | ||
# bl-hotcorners: | ||
# A script for adding hot corners to Openbox. | ||
# Repackaged for BunsenLabs by John Crawley. | ||
# Originally written for CrunchBang Linux <http://crunchbang.org/> | ||
# by Philip Newborough <corenominal@corenominal.org> | ||
# ---------------------------------------------------------------------- | ||
|
||
from Xlib import display | ||
from Xlib.ext.xtest import fake_input | ||
from Xlib import X | ||
from subprocess import Popen, PIPE, STDOUT | ||
import sys, time, os, ConfigParser, re | ||
|
||
check_intervall = 0.2 | ||
|
||
p = Popen(['xdotool','getdisplaygeometry'], stdout=PIPE, stderr=STDOUT) | ||
Dimensions = p.communicate() | ||
Dimensions = Dimensions[0].replace('\n', '') | ||
Dimensions = Dimensions.split(' ') | ||
width = int(Dimensions[0]) | ||
height = int(Dimensions[1]) | ||
hw = width / 2 | ||
rt = width - 1 | ||
bt = height - 1 | ||
|
||
def print_usage(): | ||
print "bl-hotcorners: usage:" | ||
print " --help show this message and exit" | ||
print " --kill attempt to kill any running instances" | ||
print " --daemon run daemon and listen for cursor triggers" | ||
print "" | ||
exit() | ||
|
||
if len(sys.argv) < 2 or sys.argv[1] == "--help": | ||
print_usage() | ||
|
||
elif sys.argv[1] == "--kill": | ||
print "Attempting to kill any running instances..." | ||
os.system('pkill -9 -f bl-hotcorners') | ||
exit() | ||
|
||
elif sys.argv[1] == "--daemon": | ||
Config = ConfigParser.ConfigParser() | ||
cfgdir = os.getenv("HOME")+"/.config/bl-hotcorners" | ||
rcfile = cfgdir+"/bl-hotcornersrc" | ||
bounce = 40 | ||
disp = display.Display() | ||
root=display.Display().screen().root | ||
|
||
def mousepos(): | ||
data = root.query_pointer()._data | ||
return data["root_x"], data["root_y"], data["mask"] | ||
|
||
def mousemove(x, y): | ||
fake_input(disp, X.MotionNotify, x=x, y=y) | ||
disp.sync() | ||
|
||
try: | ||
cfgfile = open(rcfile) | ||
except IOError as e: | ||
if not os.path.exists(cfgdir): | ||
os.makedirs(cfgdir) | ||
cfgfile = open(rcfile,'w') | ||
Config.add_section('Hot Corners') | ||
Config.set('Hot Corners','top_left_corner_command', 'gmrun') | ||
Config.set('Hot Corners','top_right_corner_command', '') | ||
Config.set('Hot Corners','bottom_left_corner_command', '') | ||
Config.set('Hot Corners','bottom_right_corner_command', '') | ||
Config.write(cfgfile) | ||
cfgfile.close() | ||
|
||
while True: | ||
Config.read(rcfile) | ||
time.sleep(check_intervall) | ||
pos = mousepos() | ||
|
||
if pos[0] == 0 and pos[1] == 0: | ||
if Config.get('Hot Corners','top_left_corner_command') != '': | ||
time.sleep(0.2) | ||
pos = mousepos() | ||
if pos[0] == 0 and pos[1] == 0: | ||
mousemove(pos[0] + bounce, pos[1] + bounce) | ||
os.system('(' + Config.get('Hot Corners','top_left_corner_command') + ') &') | ||
mousemove(pos[0] + bounce, pos[1] + bounce) | ||
time.sleep(2) | ||
|
||
elif pos[0] == rt and pos[1] == 0: | ||
if Config.get('Hot Corners','top_right_corner_command') != '': | ||
time.sleep(0.2) | ||
pos = mousepos() | ||
if pos[0] == rt and pos[1] == 0 : | ||
mousemove(pos[0] - bounce, pos[1] + bounce) | ||
os.system('(' + Config.get('Hot Corners','top_right_corner_command') + ') &') | ||
mousemove(pos[0] - bounce, pos[1] + bounce) | ||
time.sleep(2) | ||
|
||
elif pos[0] == 0 and pos[1] == bt: | ||
if Config.get('Hot Corners','bottom_left_corner_command') != '': | ||
time.sleep(0.2) | ||
pos = mousepos() | ||
if pos[0] == 0 and pos[1] == bt: | ||
mousemove(pos[0] + bounce, pos[1] - bounce) | ||
os.system('(' + Config.get('Hot Corners','bottom_left_corner_command') + ') &') | ||
mousemove(pos[0] + bounce, pos[1] - bounce) | ||
time.sleep(2) | ||
|
||
elif pos[0] == rt and pos[1] == bt: | ||
if Config.get('Hot Corners','bottom_right_corner_command') != '': | ||
time.sleep(0.2) | ||
pos = mousepos() | ||
if pos[0] == rt and pos[1] == bt: | ||
mousemove(pos[0] - bounce, pos[1] - bounce) | ||
os.system('(' + Config.get('Hot Corners','bottom_right_corner_command') + ') &') | ||
mousemove(pos[0] - bounce, pos[1] - bounce) | ||
time.sleep(2) | ||
|
||
else: | ||
print_usage() |
Oops, something went wrong.