You are not logged in.

#1 2018-09-30 06:27:49

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Handy config stuff or scripts (GUI version)

I originally wanted to post here, but realised that my handy snippet is Xorg (or GUI in general - let's see some wayland stuff) dependent.

So, just like its inspiration, this thread is meant for short snippets of code or configuration that might be useful in a GUI. Please post your interesting discoveries or all-time favourites!

Last edited by ohnonot (2020-06-29 17:06:10)


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#2 2018-09-30 06:43:53

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Re: Handy config stuff or scripts (GUI version)

My first is a recommendation & some configuration:
Use old X-apps and pimp them for the third millenium!
E.g. xvkbd as a virtual keyboard!
It's available, it's ultra-lightweight, it does what it should.

Why?
I sometimes watch video with mpv from a distance.
I have a wireless mouse, but not a wireless keyboard.
this helps me to control mpv.
Nice large buttons & labels, and no F keys or keypad required.

Make it a little more suitable for larger (i.e. anything beyond VGA) screens by adding this to your Xresources:

! These settings are hardcoded in xvkbd.c as fallback resouces, too,
! and this file is not required in general.
! This is intended to be included in another app-defaults files
! (XVkbd-german, for example), as:
!
!     #include "XVkbd-common"
!
! because fallback resouces may be ignored when such app-defaults file
! (application class resource file) is loaded.

! USE A DIFFERENT BITMAP FOR THE FOCUS BUTTON
!xvkbd*Focus.internalWidth: 16
!xvkbd*Focus.bitmap: /usr/include/X11/bitmaps/target

xvkbd.functionkey: false
xvkbd.keypad: false

! ADDS A SMALL ARROW TO BOTTOM LEFT
xvkbd.minimizable: true

! NO REMOTE ACCESS?
xvkbd.secure: true

! DISABLES PANEL ICON
xvkbd*wmToolbar: true

! BUT NOT ON TOP OF MPV FULLSCREEN
xvkbd*alwaysOnTop: true

! AUTO REPEAT AND DELAY
XVkbd*Repeater.initialDelay: 300
XVkbd*Repeater.minimumDelay: 30
XVkbd*Repeater.decay: 500

XVkbd*Font: -*-uniread v-medium-r-*-*-12-*-*-*-*-*-*-*
XVkbd*generalFont: -*-uniread v-bold-r-*-*-12-*-*-*-*-*-*-*
XVkbd*letterFont: -*-uniread v-bold-r-*-*-18-*-*-*-*-*-*-*
XVkbd*specialFont: -*-uniread v-bold-r-*-*-12-*-*-*-*-*-*-*
XVkbd*keypadFont: -*-uniread v-bold-r-*-*-12-*-*-*-*-*-*-*
XVkbd*banner.font: -*-uniread v-bold-r-*-*-12-*-*-*-*-*-*-*
XVkbd*display_panel*label.font: -*-uniread v-bold-r-*-*-12-*-*-*-*-*-*-*

! COLORS - LIGHT, GRAYISH
!XVkbd*Background: gray50
!XVkbd*generalBackground: gray70
!XVkbd*title*Background: white
!XVkbd*Text*background: white
!XVkbd*specialBackground: gray60
!XVkbd*focusBackground: #ff9876
!XVkbd*remoteFocusBackground: lightcyan1
!XVkbd*Foreground: black
!XVkbd*highlightBackground: gray80
!XVkbd*highlightForeground: forestgreen

! COLORS - DARK WITH GREEN GLOW
XVkbd*Background: gray5
XVkbd*generalBackground: gray10
XVkbd*title*Background: gray15
XVkbd*Text*background: gray15
XVkbd*specialBackground: gray15
XVkbd*focusBackground: #551111
XVkbd*remoteFocusBackground: lightcyan1
XVkbd*Foreground: green
XVkbd*highlightBackground: gray25
XVkbd*highlightForeground: forestgreen

! VARIOUS UI DESIGN
XVkbd*topShadowContrast: 20
XVkbd*bottomShadowContrast: 50
XVkbd*shadowWidth: 2
XVkbd*Label.shadowWidth: 0
XVkbd*MainMenu.shadowWidth: 0
XVkbd*MainMenu.topShadowContrast: 0
XVkbd*MainMenu.bottomShadowContrast: 0
XVkbd*highlightThickness: 1
XVkbd*Form.resizable: true
XVkbd*defaultDistance: 0
XVkbd*Form.borderWidth: 0
XVkbd*Label.borderWidth: 0
XVkbd*Command.internalWidth: 2
XVkbd*Repeater.internalWidth: 2
XVkbd*Command.resize: false
XVkbd*Repeater.resize: false
XVkbd*Command.justify: center
XVkbd*Repeater.justify: center

XVkbd*row1.vertDistance: 0
XVkbd*F5.horizDistance: 0
XVkbd*F9.horizDistance: 0
XVkbd*BackSpace.horizDistance: 0

! SIZES OF KEYS ETC.
XVkbd*Command.height: 50
XVkbd*Repeater.height: 50
XVkbd*row0.Repeater.height: 50
XVkbd*Command.width: 50
XVkbd*Repeater.width: 50
XVkbd*space.width: 180
XVkbd*Tab.width: 65
XVkbd*Control_L.width: 70
XVkbd*Shift_L.width: 75
XVkbd*Shift_R.width: 65
XVkbd*Multi_key.width: 50
XVkbd*Caps_Lock.width: 50
XVkbd*Alt_L.width: 50
XVkbd*Alt_R.width: 50
XVkbd*Meta_L.width: 50
XVkbd*Meta_R.width: 50
XVkbd*BackSpace.width: 90
XVkbd*Delete.width: 50
XVkbd*Return.width: 70
XVkbd*row5.Focus.width: 50
xvkbd*Mode_switch.width: 50

XVkbd*keypad.vertDistance: 0
XVkbd*keypad.horizDistance: 10
XVkbd*keypad*Command.width: 50
XVkbd*keypad*Repeater.width: 50
XVkbd*keypad*Command.justify: left
XVkbd*keypad*Repeater.justify: left
XVkbd*keypad*pad3,3.height: 100
XVkbd*keypad*pad4,0.width: 101

! TOOLTIP
XVkbd.balloonBackground: grey10
XVkbd.launchBalloonBackground: Cyan
XVkbd*balloon_panel.Label.width: 100
XVkbd*balloon_panel.Label.resize: true
XVkbd*balloon_panel.Label.justify: center

! BANNER (TOP RIGHT)
XVkbd*banner.height: 50
XVkbd*banner.width: 210
XVkbd*banner.justify: right

! MENU BUTTON (BOTTOM LEFT)
XVkbd*MainMenu.width: 50
XVkbd*MainMenu.height: 50
XVkbd*MainMenu.label: xvkbd
XVkbd*MainMenu.justify: center
XVkbd*MainMenu.internalWidth: 2
XVkbd*MainMenu.highlightThickness: 1

! MENU
XVkbd*menu*shadowWidth: 0

XVkbd*menu.about.label: About...
XVkbd*menu.man.label: Manual...
XVkbd*menu.keypad.label: Keypad...
XVkbd*menu.sun_fkey.label: Sun Function Keys...
XVkbd*menu.deadkey.label: Dead Keys...
XVkbd*menu.completion.label: Word Completion...
XVkbd*menu.select_layout.label: Change Keyboard Layout...
XVkbd*menu.edit_fkey.label: Edit Function Keys...
XVkbd*menu.show_keypad.label: Show Keypad
XVkbd*menu.show_functionkey.label: Show Function Keys
XVkbd*menu.props.label: Property...
XVkbd*menu.open_display.label: Connect to Remote Display...
XVkbd*menu.close_display.label: Revert to Local Display
XVkbd*menu.quit.label: Quit
XVkbd*menu.SmeBSB.rightMargin: 30

caveat:
if you choose a different language keyboard layout from the menu you lose some of the customisations.

Uniread V is part of the excellent Linux Font Project. get the lfpfonts package from here.

I have added a miniscript 'xvkbd-toggle' to my ~/bin and to my openbox menu:

#!/bin/sh
pidof xvkbd && killall xvkbd || xvkbd &
exit

dark version:
http://dt.iki.fi/stuff/forums/xvkbd.png
btw, the "xvkbd" logo on the bottom left opens the menu.

Last edited by ohnonot (2018-09-30 07:54:43)


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#3 2018-09-30 06:58:20

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Re: Handy config stuff or scripts (GUI version)

Quick Urbandictionary Lookup

somebody invoked Rule 34A on reddit. everybody else seems to understand, but you don't.
obviously you won't find this on wikipedia.
with my script (best bind it to a hotkey in rc.xml) you can highlight the term in question, execute the script, and get results in color and nicely formatted.

the script uses xclip by default to get the selection, and opens the results in a suitably sized terminal (*), but it recognizes if you give a search term on the command line or if it's run from a terminal interactively, and will behave accordingly.

(*) i use the custom environment variable $XTERMINAL to define my default terminal. if this is undefined, the script defaults to xterm.

#!/bin/bash

# if you want to:
#~ XTERMINAL=something_else

# how many results do you want max.
max=3

if [ -t 0 ]; then 
	width="$(tput cols)"
else
	# define width here
	width=60
fi

# which character the header line consists of
headchar=":"

function header { # outputs a header with string $1 in the middle
	x=$width
	half=$(( ( $x - ${#1} ) / 2 ))
	x=$(( $x - ( $half + $half + ${#1} ) ))  
	putline $half "$headchar"
	echo -n "$1"
	putline $half "$headchar"
	echo
}
function putline { # outputs a line $1 long, consisting of $2 characters
    for (( p=1; p<=$1; p++ )); do
       echo -n "$2"
    done
}

# xclip or command line $1?
[[ "$@" == "" ]] && term="$(xclip -o)" || term="$@"
[[ "$term" == "" ]] && echo "no input :(" && exit 1

# terms with spaces etc: systutorials.com/241492/how-to-encode-spaces-in-curl-get-request-url-on-linux
stuff="$(curl -sG --data-urlencode "term=$term" "https://api.urbandictionary.com/v0/define")"

string=""
fullstring=""
for (( i=0 ; i<$max ; i++ )); do
	# build a header out of number & word, if available
	word="$(echo "$stuff" | jshon -e list -e $i -e word -u)"
	[[ "$word" == "" ]] && break
	string="$(echo "$stuff" | jshon -e list -e $i -e definition -u | fold -s -w $width)\n\nExample:\n\n$(echo "$stuff" | jshon -e list -e $i -e example -u | fold -s -w $width)"
	# if there's an actual definition, print it out
	# if there's an example, print it out
	# remove square and curly brackets from definition & example
	string="${string//[/}"
	string="${string//]/}"
	string="${string//\{/}"
	string="${string//\}/}"
	# add color & header to front of string, and add it to fullstring
	color="$((i+1))"
	(( color > 7 )) && color="$((i-6))"
	string="\e[0;3${color}m$(header " $((i+1)): $word ")\n\n$string"
	(( i > 0 )) && fullstring="$fullstring\n\n$string" || fullstring="$fullstring$string"
done
[[ "X$fullstring" == "X" ]] && fullstring="Nothing found for \"$term\" :("

title="\"$term\" on urbandictionary.com"

if [ -t 0 ]; then
	echo -e "$title\n\n$fullstring"
else
	# If stdin is not a tty, start it in a terminal - unix.stackexchange.com/a/26691
	height="$(echo -e "$fullstring"|wc -l)"
	((height++))
	# don't let it get too tall
	(( height > 60 )) && height=60
	${XTERMINAL-xterm} -T "$title" -geometry ${width}x${height} -e bash -c 'tput civis; echo -en "$@"; read' ud "$fullstring"
fi

screenshot:
http://dt.iki.fi/stuff/forums/ud.png

PS: except for xclip, this isn't even gui dependent.

Last edited by ohnonot (2018-09-30 07:56:25)


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#4 2020-07-19 20:40:47

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Re: Handy config stuff or scripts (GUI version)

For years I've been using my terminal screensaver termss.
Today I had another coding fit and finally made some options not hardcoded (through simple sourced config files rather than command line options) and generally cleaned up. Also improved the star sprinkle.
Hopefully it's more useful to others now.
Check it out:
https://notabug.org/ohnonot/termss or
https://framagit.org/ohnonot/termss

Animated screenshot:
https://framagit.org/ohnonot/termss/-/r … 233924.gif


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#5 2020-07-19 21:34:32

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

Re: Handy config stuff or scripts (GUI version)

Looks good.
hhpc something like unclutter in debian repos?
https://wiki.debian.org/unclutter


Што ни оштровиди ум сагледати не може - љубав превазилази.

Offline

#6 2020-07-20 08:59:23

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Re: Handy config stuff or scripts (GUI version)

IIRC unclutter provides tray icon and such. hhpc just hides the mouse cursor, nothing else. It's not required for the screensaver script to work, but who wants their mouse cursor visible when the screensaver is active...


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#7 2020-07-20 10:54:21

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

Re: Handy config stuff or scripts (GUI version)

^good point
It can run with termsaver also

apt install termsaver

or pip

sudo pip install termsaver

Then

termss  sh -c  "/usr/bin/termsaver clock"

or

termss  sh -c  '/usr/bin/termsaver randtxt --word "$(date)" --delay 1'
termss  sh -c  "/usr/bin/termsaver asciiartfarts"

Last edited by misko_2083 (2020-07-20 11:54:57)


Што ни оштровиди ум сагледати не може - љубав превазилази.

Offline

#8 2020-07-20 13:22:55

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Re: Handy config stuff or scripts (GUI version)

So my script actually works on BL?
Great.

termsaver is interesting; need to play with it.
Unfortunately it depends on python2, which will make my script the better alternative in the future wink

termsaver commands should be prepended with 'tput civis;'
The 'matrix' profits from ''.

Also try 'cmatrix|lolcat'!


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#9 2020-07-21 11:03:14

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Re: Handy config stuff or scripts (GUI version)

I edited the script, tried to make it more robust, added text to the README.
It can also use unclutter now to hide the mouse pointer, thanks misko!


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#10 2020-07-21 16:48:20

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

Re: Handy config stuff or scripts (GUI version)

Good stuff.
this line can be changed to work with xterm.

xterm +bc -uc -fa "$font" -b 0 -w 0  -fullscreen -geometry "${term_w}x$term_h" -e "$@" & urxvtpid=$!

Што ни оштровиди ум сагледати не може - љубав превазилази.

Offline

#11 2020-07-21 21:00:24

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Re: Handy config stuff or scripts (GUI version)

^ Interesting.
Anyhow, I don't see a problem with a hard dependency for urxvt, it should be available in every & all distros' repo's, no?


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#12 2020-07-22 16:24:34

ohnonot
...again
Registered: 2015-09-29
Posts: 4,782
Website

Re: Handy config stuff or scripts (GUI version)

Misko, would you consider testing the latest version?
I changed the way terminal size is detected; instead of faffing around with xlsfonts it simply opens a 1x1 terminal and lets xdotool get its size.
This is so fast and invisible it can happen dynamically each time the ss activates.

And please tell me if you think a choice between urxvt/xterm and possibly others is necessary.


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

Board footer

Powered by FluxBB