Giter VIP home page Giter VIP logo

bunsen-utilities's Introduction

bunsen-utilities
================

A collection of small scripts to provide various functions
which might be useful to BunsenLinux users and system administrators.

beepmein:               Alarm clock script based on "at".

bl-imgbb-upload:        Take screenshots and upload them to Imgbb.
bl-imgur-upload:        Take screenshots and upload them to Imgur.
bl-image-upload:        Generic BunsenLabs image upload utility.

bl-conkyedit:           Find and edit conky config files.
bl-conky-manager:       Yad-based conky manager.
bl-conkymove:           Assist the movement of conky windows.
bl-conky-session:       Handle multiple conky sessions.

bl-tint2edit:           Find and edit tint2 config files.
bl-tint2-manager:       Yad-based tint2 manager.
bl-tint2-restart:       Restart all running tint2 processes.
bl-tint2-session:       Handle multiple tint2 sessions.

bl-kb:                  Read openbox keyboard shortcuts and write them to a text file.
bl-xbk:                 Parse xbindkeys configs and write them to the same text file as bl-kb.
bl-lock:                Lock the display.
bl-setlocale:           Yad-based script to allow users to choose their locale.

bl-pkg-versions:        Utility to display the versions of BunsenLabs packages in the apt repository and on GitHub.
bl-notify-broadcast:    Send user notification popups from root processes.
bl-urxlx:               Convert Xresources colours to rgb for lxterminal configuration.
bl-xinerama-prop:       Get xinerama properties in a shell script.
bl-reload-gtk23:        Script to notify GTK2/3 clients of GTK2/3 app configuration changes such as theming.

bunsen-utilities's People

Contributors

2ion avatar capn-damo avatar hjdskes avatar johnraff avatar samwhelp avatar xaosfiftytwo avatar xurxof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bunsen-utilities's Issues

bl-exit/merlin branch - test for icon dimensions

ATM the default icons are 100x100px, but the gui panel can be set to any height. This means that the images are cut off if the height is less than 100.

Either we could limit the panel height to 100px minimum, or allow scaling of the icons (say between about 48 and 128). Scaling is a neater solution IMO, but I think the buttons should be proportional to the icon, not the window.

bl-kb --gui outputs unnecessary text

bl-kb when called with the --gui option, apart from writing to kbinds.txt for reading by yad, also outputs the same content to stdout. This is not needed when using yad, and if the command is issued without a terminal (eg from the openbox menu) then the result just goes into ~/.xsession-errors.

It can be avoided by editing line 101 to have print(line) executed only when `--gui`` has not been used, ie by adding another indent. That section would thus look like:

def output_keybinds(arrShortcut,gui):
    """loop through array, and format output then write to file"""
    for i in range(0,len(arrShortcut)):
        exe=str(arrShortcut[i][0])
        keybinding=str(arrShortcut[i][1])
        execute=str(arrShortcut[i][2])
        if gui:     #format output for text window
            if len(execute)>80 :
                execute=execute[:75]+"....."
            line = "{:2}".format(i) + "\t" + "{:<16}".format(keybinding)\
            + "\t" + execute
        else:   #format text for pipemenu
            line = exe + "{:<16}".format(keybinding) + "\t" + execute
            print(line)
        write_file(line)

If this were done, the error message on line 48 should be changed to:

            msg = "\n\n\tUSAGE: to display keybinds in a text window use 'bl-kb --gui'\n\n"

ie redirection to /dev/null would not be needed.

BunsenLabs/bunsen-pipemenus#46

bl-tint2-restart needs to be stricter

With default tint2 processes (no -c argument) bl-tint2-restart does not kill all, and duplicate processes are perpetuated.

john@bunsen:~$ pgrep -a tint2
8151 /bin/bash /usr/bin/bl-tint2-session
8260 tint2
9068 tint2
9086 tint2

After Settings>Tint2>Restart tint2, one more process has been added:

john@bunsen:~$ pgrep -a tint2
8151 /bin/bash /usr/bin/bl-tint2-session
8260 tint2
9176 tint2
9178 tint2
9180 tint2

After running the suggested new restart script:

john@bunsen:~$ pgrep -a tint2
9330 tint2

@capn-damo would it be OK to substitute this harsher restart script? It uses the KILL signal to make sure existing processes are really stopped, and only starts one instance of processes that have the same command line.

#!/bin/bash
#
# bl-tint2restart to be used by bl-tint2-pipemenu
# Written for BunsenLabs Linux by <damo> June 2015

declare -A commands # associative array
while read pid cmd; do
    if [[ ${cmd%% *} = tint2 ]]; then
        kill -KILL "$pid"
        commands[$cmd]=1 # duplicate commands will be launched only once
    fi
done <<< "$(pgrep -a tint2)"

sleep 1
for i in "${!commands[@]}" # go through the indexes
do
    (setsid $i &)
    sleep 0.1
done

sleep 1
bl-compositor --restart  # restart compositor

exit 0

bl-aerosnap fails if window is undecorated

If the active window is undecorated, then after left/right snaps the top of the window is off the screen. The script then doesn't get the window geometry and fails.

Traceback (most recent call last):
File "/home/damo/bin/bl-aerosnap", line 126, in <module>
window_store()
File "/home/damo/bin/bl-aerosnap", line 76, in window_store
s = ID +'|'+window_geometry(ID)+'\n'
TypeError: cannot concatenate 'str' and 'NoneType' objects

bl-hotcorners rewrite

I enjoyed rewriting bl-aerosnap and contributing to BunsenLabs so much that I also took a look at the other python scripts. Whilst I'm waiting for feedback on my bl-aerosnap rewrite, I'm now working on bl-hotcorners. You can find it in the rewrite-hotcorners branch of my fork.

bl-hotcorners is supposed to run as a daemon. The current code, however, does not implement proper daemon behaviour. After a bit of searching, I came acros python-daemon which does all the tricky work for you. I'm wondering if I can make bl-hotcorners depend on that. The package is available in Jessie.

Otherwise, I can copy this code, which also does a lot of the heavy lifting.

Edits to bl-tint2zen, bl-tint2-session etc

@2ion @johnraff
Hopefully the commit messages are comprehensive enough:

Added bl-tint2restart to restart tint2s from the pipemenu;
Various bugfixes and improvements to getting/killing tint2 processes;
Remove --autostart command arg, so tint2s now killed and restarted anyway;
Made bl-tint2edit and bl-conkyedit executable (previously overlooked)

aerosnap limping on deprecated syntax

So got around to incorporating aerosnap in my setup and noticed this problem. The lint indicated that the syntax in lines 115 and 123 is deprecated. The funny thing is that the conditional works because of the deprecated syntax. Consider,

elif sys.argv[1] == "--left":
    if is_root_window != True:       <===
        if window_lookup():
            window_restore(width)

is_root_window is actually a function and should have been called. Rather the value of the reference (which is the function object) is being tested against True which would always result in the conditional being true (and the program would enter the subsequent loop) even when the window is the root window. Not that it would bring about any drastic change (like changing the geometry of the root window), but I thought I would mention it for the sake of correctness.

I have prepared the following patch. The rest of the edits are just lint-based. No changes in the logic.

diff --git a/bl-aerosnap b/bl-aerosnap
index c77859d..b05fa3f 100755
--- a/bl-aerosnap
+++ b/bl-aerosnap
@@ -7,13 +7,15 @@
 # ----------------------------------------------------------------------

 from subprocess import Popen, PIPE, STDOUT
-import sys, time, os, re
+import sys
+import os
+import re

 history = '/tmp/bl-aerosnap-'+str(os.getuid())
 windows = {}
 check_intervall = 0.2

-p = Popen(['xdotool','getdisplaygeometry'], stdout=PIPE, stderr=STDOUT)
+p = Popen(['xdotool', 'getdisplaygeometry'], stdout=PIPE, stderr=STDOUT)
 Dimensions = p.communicate()
 Dimensions = Dimensions[0].replace('\n', '')
 Dimensions = Dimensions.split(' ')
@@ -22,12 +24,12 @@ 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"
+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')
+if not os.path.exists(history):
+    f = open(history, 'w')
     f.close()

 def print_usage():
@@ -56,7 +58,7 @@ def window_id():
 def window_lookup():
     ID = window_id()
     windows = history_load()
-    if windows.has_key(ID):
+    if ID in windows:
         return True

 def window_geometry(ID):
@@ -73,8 +75,8 @@ def window_geometry(ID):
 def window_store():
     ID = window_id()
     windows[ID] = window_geometry(ID)
-    s = ID +'|'+window_geometry(ID)+'\n'
-    f = open(history,'a')
+    s = ID + '|' + window_geometry(ID) + '\n'
+    f = open(history, 'a')
     f.write(s)
     f.close()

@@ -92,14 +94,13 @@ def window_restore(width):
         for key in windows:
             h = windows[key].split('|')
             o = key+'|'+h[0]+'|'+h[1]+'|'+h[2]+'|'+h[3]+'\n'
-    f = open(history,'w')
+    f = open(history, 'w')
     f.write(o)
     f.close()
     os.system(command)

 def history_load():
-    f = open(history,'r')
-    i = 0
+    f = open(history, 'r')
     for line in f:
         h = line.split('|')
         h[4] = h[4].replace('\n', '')
@@ -111,7 +112,7 @@ if len(sys.argv) < 2 or sys.argv[1] == "--help":
     print_usage()

 elif sys.argv[1] == "--left":
-    if is_root_window != True:
+    if not is_root_window():
         if window_lookup():
             window_restore(width)
         else:
@@ -119,7 +120,7 @@ elif sys.argv[1] == "--left":
             os.system(aeroLcommand)

 elif sys.argv[1] == "--right":
-    if is_root_window != True:
+    if not is_root_window():
         if window_lookup():
             window_restore(width)
         else:

bl-aerosnap bug and issue

Bug: The help message asks to use "--aero-left". The code itself uses "--left".

Another issue: The current script doesn't respect "margins" (many people set 1 or 2 pixels of margins under openbox).

bl-exit/merlin: Need test for current monitor

ATM we have
(_, _, width, _) = gtk.gdk.Screen(BlexitWindowMerlin).get_monitor_geometry(0)

This works if the Openbox placement policy is "Smart", but not if it is "UnderMouse"

To ensure the exit dialog appears on a specified monitor, and not under the mouse on another one, and with the correct width, rc.xml needs to have

    <application class="Bl-exit" name="bl-exit">
      <position force="yes">
        <x>center</x>
        <y>center</y>
        <monitor>1</monitor>
      </position>
      <focus>yes</focus>
      <decor>no</decor>
      <shade>no</shade>
      <desktop>all</desktop>
      <maximized>horizontal</maximized>
      <fullscreen>no</fullscreen>
    </application>

This seems a bit clumsy, and requires the user to edit 2 scripts. Slightly better I think is to have a global var at the top of bl-exit:

monitor = 0
etc
(_, _, width, _) = gtk.gdk.Screen(BlexitWindowMerlin).get_monitor_geometry(monitor)

A better solution might be to detect where the mouse is, set monitor that way, and do away with the openbox config. And would this need to determine if "Smart" or "UnderMouse" is being used?

hotkeys for bl-exit

in older version you had em
line 40-43, a simple underscore in from of the label string,
highly appreciate your work, pls reimplement, ty
`

    self._add_button(label="_Log out", action=self._logout_action)
    self._add_button(label="_Suspend", action=self._suspend_action)
    self._add_button(label="_Reboot", action=self._reboot_action)
    self._add_button(label="_Power off", action=self._shutdown_action)

`

bl-exit --logout fails

Since os.system was replaced the logout option no longer works:

~$ bl-exit -l
Traceback (most recent call last):
  File "/usr/bin/bl-exit", line 151, in <module>
    main(sys.argv[1:])
  File "/usr/bin/bl-exit", line 135, in main
    logout()
  File "/usr/bin/bl-exit", line 105, in logout
    os.system("openbox --exit")
NameError: global name 'os' is not defined

On line 105, replacing os.system("openbox --exit") with call("openbox --exit") produced:

Execution failed:  [Errno 2] No such file or directory

bl-tint2-zen/bl-tint2-session "orphan" processes?

tint2's are started from commands kept in the sessionfile, with source "$SESSIONFILE"
This creates another process for each tint2 which was started, called
/bin/bash /home/damo/bin/bl-tint2-session or /bin/bash /home/damo/bin/bl-tint2zen

They can be killed manually later without killing the tint2's, but killing the PIDs within the scripts kills the tint2's as well. My bash skills aren't good enough to have found a solution :(

bl-kb does not handle Keybinds wih multiple actions

Hi,

If you create an action in rc.xml like this:


    <keybind key="W-Left">
      <action name="UnmaximizeFull"/>
      <action name="MaximizeVert"/>
      <action name="MoveResizeTo">
        <width>50%</width>
        <x>0</x>
        <y>0</y>
      </action>
    </keybind>

bl-kb will not handle it correctly and it will not appear in Keybindings list. It seems that it is any Keybinding with more that one action that cause this issue.

Regards,

TB

bl-obthemes: function countMonitors() fails if no primary monitor is set

Situation: on a new install with dual monitors, but before setting the screen layout with arandr/xrandr.
What happens: bl-obthemes doesn't start, with the error

/usr/bin/bl-obthemes: line 200: / 3 : syntax error: operand expected (error token is "/ 3 ")

  Error= 255

In function countMonitors() is
PRIMARY=$(xrandr -q | awk '/ connected/ {if ($3=="primary") print $4}')
but there is no "primary" field found.

Setting --primary specifically with xrandr results in bl-obthemes running OK.

Quick workaround: get a monitor dimension (which may not be the desired one) by changing line #180 to
PRIMARY=$(xrandr -q | awk '/ connected/ {if ($3=="primary") print $4;else print $3}')

ToDo: test for "main" monitor - either the largest, or the one at +0+0?

When bl-tint2-session load tint2-sessionfile, empty line launch default tint2rc.

When bl-tint2-session load tint2-sessionfile, empty line launch default tint2rc.

Description

If ~/.config/tint2/tint2-sessionfile has empty line.

When bl-tint2-session load tint2-sessionfile,

empty line got the fullPath /home/user/.config/tint2/

So it will run command as follow

tint2 -c /home/user/.config/tint2/

show message like this

...
tint2: Loading config file: /home/user/.config/tint2/
...

So i created pull request #74 to fix this situation.

bl-conky-manager ignores symlinks to conky files

Line 152 in bl-conky-manager test for the existence of a "regular file" ([[ -f $file ]]) and will ignore anything else. I assume this was done to skip over directories, etc., but it also ignores symlinks. (I found that because I keep a conkyrc I created elsewhere and wanted to link it into the directory to use it with the conky manager; I worked around this with a hardlink, but that is not always an option.) Unless there is a good reason (i.e. something does not work with symlinks), I would suggest fixing that, either by changing the test to just exclude directories ([[ ! -d $file ]]) or by explicitly allowing symlinks ([[ -f $file ]] || [[ -L $file ]]). (There are several other things that could fail and that one could test for, e.g. files without read permissions, but these are not common and one can almost never test for every possible contingency.) Thanks!

bl-exit - typo fixed

Needed a space before username:
self.set_title("Log out " + getpass.getuser() + "? Choose an option:")

bl-obthemes: firefox-esr icon lost when restoring

When restoring a saved configuration, the firefox-esr icon in the tint2 panel appears as a generic icon.

Could this be due to function reloadGTK no longer working properly with the new firefox?

Edit to bl-tint2-session

bl-tint2-session: Create sessionfile when 'tint2' command is used for the first time, with no file specified.

bl-lock

Just noticed that

bl-lock --help

from the command line locks the screen, where I expected usage notes to see with which arguments it can be run.

bl-reload-gtk23 error message when reloading running xsettingsd

bl-reload-gtk23: function sync_gtk3():
If xsettingsd is already running, the HUP signal is correctly sent, but the script returns with an error message:
WARNING bl-reload-gtk23 main() : Failed to reload GTK3 settings: 'int' object is not callable
The utility returns 2 but otherwise seems to work as expected.
If xsettingsd is not yet running, and needs starting, no error is thrown.

Inspection of the code suggested this line:

logging.debug("Found xsettingsd process and sent SIGHUP: PID %d", proc.pid())

If edited to:
logging.debug("Found xsettingsd process and sent SIGHUP: PID %d", proc.pid())
(by analogy with line 139) then the issue appears to be fixed.
However, this was a purely empirical fix and needs attention from the developer.

CONKYPATH in bl-conkyzen and bl-conky-session

atm it is CONKYPATH="$HOME/.conky" but presumably it should be CONKYPATH="$HOME/.config/conky", to bring it into line with all the other .config applications. The default conkyrc would then be a symlink: $HOME/.conkyrc -> $HOME/.config/conky/.conkyrc.

Conkys need to be in $CONKYPATH, but if the user has symlinks in .config to multiple conky dirs, then the conky search path needs to use find -L "$CONKYPATH". This is likely to make the gui load slowly if find has to traverse a lot of dirs.
Leave the choice of find -L to the user? Presumably if they have got that far they already know how to set up symlinks and use find?

I could make a pipemenu link to a help-doc, to expand on usage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.