LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 11-25-2017, 05:48 PM   #16
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
yad alarm


Alarm script. Set delay in minutes (supports fractional parts i.e. 0.25 for 15 seconds). Shows a progress bar (countdown) before either being cancelled or triggering a alarm sound (needs mpv to play the sound file, or change the code to use mplayer or whatever).

Code:
#!/bin/sh

# Rufwoof Nov 2017
# OpenBSD yad alarm script

TITLE="Alarm"
VERSION=0.1

SOUND='/home/user/bin/alarm.mp3'
ICON=/home/user/.twm/icons/clock28x34.png

# Prompt for delay in minutes before alarm
# Fractional parts of minute supported i.e. 0.0833 is 5 seconds
DELAY=$(yad --entry --text "Enter minutes..." --title="$TITLE"" $VERSION" --window-icon=$ICON \
			--image=$ICON \
			--button="gtk-ok:0" \
			--button="gtk-close:1" \
		   )
ret=$?
[[ $ret -eq 1 ]] && exit 0

# Convert to seconds
DELAY=`echo "$DELAY*60"|bc -l`

# Make a proportion of 1/100ths 
STEP=`echo "$DELAY/100"|bc -l`

# Show a progress/countdown meter
i=0
while [ "$i" -lt 101 ]
do
    echo $i
    echo "# Remaining $((100-i))% to finish the job"
    sleep $STEP
    i=`expr $i + 1`
done | yad --progress --center --text="Alarm Countdown progress ..." --button=gtk-cancel:1 --auto-kill --auto-close
ret=$?
[[ $ret -eq 1 ]] && exit 0


# Use mpv to play the alarm sound put it into the background recording its PID
mpv --loop=inf "$SOUND" &
PID=$! 

# Show a stop alarm dialog
yad --title "$TITLE"" $VERSION" \
                 --button="gtk-ok:0" \
                 --width 300 --image=$ICON \
                 --window-icon=$ICON \
                 --text="<b>Time is over!!</b>"
# kill mpv
kill -1 $PID
Attached Thumbnails
Click image for larger version

Name:	alarm1.jpg
Views:	10
Size:	61.7 KB
ID:	26403   Click image for larger version

Name:	alarm2.jpg
Views:	10
Size:	65.8 KB
ID:	26404   Click image for larger version

Name:	alarm3.jpg
Views:	10
Size:	14.3 KB
ID:	26405  

Last edited by rufwoof; 11-25-2017 at 05:51 PM.
 
Old 11-25-2017, 06:08 PM   #17
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
yad menu launched directly via right click desktop or window title bar

I've switched from using a right click of the desktop or window title bar warping to the gkrellm clock, which when clicked brought up the yad programs menu, to just simply directly launch the yad menu, positioning it near the mouse and accounting for screen edges. It also tests to see if another menu was already open and if so closes that before presenting the new menu window.

twm icons ... not that nice so I'm not using them. The icon manager is nice however especially in being able to set colour themes for different programs. twm menu navigation with its slider (press/drag) ... again not particularly nice IMO and replacing that with a click type yad menu also has nicer fonts/look. So fundamentally twm is being used as the base window manager and for its icon manager that acts like a panel/task-list, whilst yad provides the menus (and ease of writing scripts such as alarm, diary ...etc.).

Code:
#!/bin/sh
# Kill prior running version (prevent duplicates)
ID=`xdotool search --onlyvisible --name Apps`
if [ "$ID" != "" ]; then
  /tmp/PIDofChooseProgram &
fi

SCREENSIZE=`xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/'`
MAXX=`echo $SCREENSIZE | awk 'BEGIN { FS = "x" } ; { print $1 }'`
MAXY=`echo $SCREENSIZE | awk 'BEGIN { FS = "x" } ; { print $2 }'`
MAXX=`expr $MAXX - 300`
MAXY=`expr $MAXY - 475`

# Where is mouse
MOUSEX=`xdotool getmouselocation --shell | grep X= | sed s/X=//`
MOUSEY=`xdotool getmouselocation --shell | grep Y= | sed s/Y=//`
if [ "$MOUSEX" -gt "$MAXX"  ]; then
   MOUSEX=$MAXX
fi
if [ "$MOUSEY" -gt "$MAXY"  ]; then
   MOUSEY=$MAXY
fi


GEO="--geometry=300x475+${MOUSEX}+${MOUSEY}"


yad --icons \
--read-dir=/home/user/Desktop \
--sort-by-name \
--single-click \
--no-buttons \
--compact \
$GEO \
--title=Apps &
echo "kill -1 $!" >/tmp/PIDofChooseProgram
chmod +x /tmp/PIDofChooseProgram
The menu is automatically built according to whatever .desktop files are present in the Desktop directory, however I've manually sized the yad menu window in reflection of that.

Animated gif : https://s33.postimg.org/jqlcyjrgv/ani.gif

Last edited by rufwoof; 11-25-2017 at 06:13 PM.
 
Old 12-03-2017, 12:54 PM   #18
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 276

Rep: Reputation: 131Reputation: 131
With twm, vdesk is a nice addition, it will give you psuedo virtual desktops.

Code:
"F2"	= m : all	: f.exec vdesk 2
 
Old 12-03-2017, 05:33 PM   #19
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
Thanks for the reminder. I've been intending to have a look at vdesk (never having used it), but in truth I have little need/desire for multi-desktops as multi-full screen windows on a single desktop and ease of switching between them is just as effective IMO. I guess handy if you use multi-monitors, but again I just use the one. In my other multi-boots that support multiple desktops I've always tended to reconfigure to just have the one.

I was running under a nvidia card before adopting OpenBSD (for which I removed it to use the onboard Radeon ATI as that works better under OBSD) and that nvidia's panning option was nice ... for some fun i.e. create a virtual desktop space much larger than the actual display resolution ... and when you moused to a screen edge it moved the window around that larger space. But that is annoying when it comes to real work ... such as reaching (mousing) for the vertical scrollbar down the right hand screen edge and having the screen shift (pan) rightwards. Also tends to induce a sea-sickness type sensation when you move around looking for where you'd left a window.

Last edited by rufwoof; 12-03-2017 at 05:34 PM.
 
Old 12-03-2017, 05:38 PM   #20
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
f.fullzoom under OpenBSD twm doesn't work as expected. Maximises OK, but the first click to restore brings up a mouse cursor and you have to click a second time for the restore to work.

A workaround that works for me is to create a function

Function "fullscreen" { f.fullzoom f.winrefresh }

and call that instead, such as

LeftTitleButton "maximize.xbm" = f.function "fullscreen"
 
Old 12-03-2017, 05:44 PM   #21
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
I've switched over to using tab like window titles i.e. defining

SqueezeTitle

Nice how when a window is maximised the space to the right of the window title tab has the desktop showing so you can left mouse press that to present the normal menu that shows when the desktop is left mouse pressed.

https://postimg.org/image/mopb5riez/
 
Old 12-05-2017, 06:00 PM   #22
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
Volume control

Added a middle mouse (scrollwheel) desktop press bringing up a twm menu that sets the volume level

So with tab window titles even if a window is full screen you can still see some desktop space to activate the sound menu (or other menus/icon manager ...etc.

The menu definition that I used for that volume menu in .twmrc is ...

Code:
menu "Volume" 
{
   "Volume"					f.title
   "   0%"      ( "#00B6FF" : "black"   ) 	!"mixerctl -q outputs.master=0"
   "   5%"      ( "#00B6FF" : "black"   )  	!"mixerctl -q outputs.master=13"
   "  10%"      ( "#00B6FF" : "black"   )  	!"mixerctl -q outputs.master=26"
   "  15%"      ( "#00B6FF" : "black"   )  	!"mixerctl -q outputs.master=38"
   "  20%"      ( "#00B6FF" : "black"   )  	!"mixerctl -q outputs.master=51"
   "  25%"      ( "#00B6FF" : "black"   )  	!"mixerctl -q outputs.master=64"
   "  30%"      ( "#00B6FF" : "black"   )	!"mixerctl -q outputs.master=77"
   "  35%"      ( "green" : "black"     )  	!"mixerctl -q outputs.master=89"
   "  40%"      ( "green" : "black"     )  	!"mixerctl -q outputs.master=102"
   "  45%"      ( "green" : "black"     )  	!"mixerctl -q outputs.master=115"
   "  50%"      ( "green" : "black"     )  	!"mixerctl -q outputs.master=128"
   "  55%"      ( "green" : "black"     )  	!"mixerctl -q outputs.master=140"
   "  60%"      ( "green" : "black"     )	!"mixerctl -q outputs.master=153"
   "  65%"      ( "green" : "black"     )	!"mixerctl -q outputs.master=166"
   "  70%"      ( "red" : "black" 	)	!"mixerctl -q outputs.master=179"
   "  75%"      ( "red" : "black" 	)	!"mixerctl -q outputs.master=191"
   "  80%"      ( "red" : "black" 	)	!"mixerctl -q outputs.master=204"
   "  85%"      ( "red" : "black" 	)	!"mixerctl -q outputs.master=217"
   "  90%"      ( "red" : "black" 	)  	!"mixerctl -q outputs.master=230"
   "  95%"      ( "red" : "black" 	)  	!"mixerctl -q outputs.master=242"
   " 100%"     	( "red" : "black" 	)	!"mixerctl -q outputs.master=255"
}
Attached Thumbnails
Click image for larger version

Name:	s2.png
Views:	15
Size:	114.0 KB
ID:	26484  
 
Old 12-15-2017, 12:19 PM   #23
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
Simple alarm using "at" command

Create a alarm.sh script in your bin folder, something like the following (this assumes mpv is installed and a sound file called alarm.mp3 exists)
Code:
#!/bin/sh
export DISPLAY=:0.0
/usr/X11R6/bin/xterm -e "/usr/local/bin/mpv --loop=inf /home/user/alarm.mp3"
Create another script called alarm ....
Code:
#!/bin/sh
at -f /home/user/bin/alarm.sh $1
echo 
echo list jobs with at -l
echo "remove job with at -r <job>"
Make both script executable (chmod +x alarm.sh)

Now when in a terminal when you run alarm 19:24 or whatever time you choose, a "at" job will run at that time that sounds the alarm.

To list current at jobs running use

at -l

You can remove a at job using

at -r <job>

i.e. the job number as shown when the job was started or when jobs are listed using the at -l command.

When the above alarm sounds/triggers it opens a xterm window that shows the mpv playing of the the sound file and Ctrl-C will close that program (stop the alarm).
 
Old 12-15-2017, 12:32 PM   #24
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
Minimal OpenBSD

Standard OpenBSD installed with just firefox-esr added on top of that provides a modest minimal desktop environment.

Use twm as the window manager
xedit for text editing
xcalc calculator
xterm as your terminal
firefox supports opening PDF files, can browse local files (use a URL of file:///), can view images, play videos, sounds, act as a radio station player ...etc. You can even edit images, create animated gifs, use a online wordprocessor or spreadsheet, maintain a diary/calendar ...etc. all via online services.
Using scripts such as the alarm I posted in the previous post you can extend the functionality without having to pull in additional third party programs.

And that's relatively quick and easy to upgrade every 6 months as and when a new release of OpenBSD occurs.
 
Old 12-16-2017, 11:13 AM   #25
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
OpenBSD, twm, yad

Rearranged my yad menubar, volumebar and iconmanager layout so that the volume bar is the same height as the menubar and alongside it, and the icon manager spans a much greater width of the screen and starts alongside the volume bar. Attached is a animated gif of when I right click on the desktop i.e. to the right of a maximised windows title tab, up pops the menubar, volume bar and icon manager list.
Attached Thumbnails
Click image for larger version

Name:	a.gif
Views:	13
Size:	131.9 KB
ID:	26538  
 
Old 12-20-2017, 04:09 PM   #26
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
Radeon ATI acceleration

Inspecting /var/log/Xorg.0.log and it was apparent I wasn't using acceleration for my Radeon ATI.

Adding

Code:
Option "Accelmethod" "glamor"
to /etc/xorg.conf and rebooting had /var/log/Xorg.0.log indicating I also needed to add

Code:
machdep.allowaperture=1
to /etc/sysctrl.conf. After doing that and rebooting yet again all is running well.
 
Old 03-01-2018, 12:18 PM   #27
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
Tweaked my .twmrc to contain

"Left" = m : all : f.exec "mixerctl outputs.master=-12"
"Right" = m : all : f.exec "mixerctl outputs.master=+12"

so that sound volume can be increased/decreased using ALT and left/right arrow

As a side note, twm comes as part of the X Windows system, so at least in concept it is the only windows manager common to all Unix like systems that run X window system.

I had been following OpenBSD current, however after a number of mismatches between the base system and packages I've reverted back to using -release, with that being updated (so -stable) using openup. Binary patches/fixes as easy as downloading openup from mtier and then running it (takes just a minute or two to run).

https://www.mtier.org/solutions/apps/openup/
 
Old 05-25-2018, 01:33 PM   #28
rufwoof
Member
 
Registered: Nov 2017
Distribution: Debian Desktop; OpenBSD Server
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rufwoof View Post
Inspecting /var/log/Xorg.0.log and it was apparent I wasn't using acceleration for my Radeon ATI.

Adding

Code:
Option "Accelmethod" "glamor"
to /etc/xorg.conf and rebooting had /var/log/Xorg.0.log indicating I also needed to add

Code:
machdep.allowaperture=1
to /etc/sysctrl.conf. After doing that and rebooting yet again all is running well.
glamor was causing problems with large/rapid xterm lists, such as finding all files or tar'ing ...etc. where the terminal screen would just lock-up. Changing the Accelmethod to EXA fixed that.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ratpoison Maximise a Window? Gavin Harper Linux - Software 0 02-02-2011 06:38 AM
middle click the maximise button to maximise vertically in gnome? dasy2k1 Linux - Newbie 1 05-10-2009 08:58 PM
CentOS window does not maximise with VBOX decepticon Linux - Newbie 2 05-03-2009 07:53 PM
maximise and minimise Patrick-Warwick Linux - Desktop 6 01-03-2009 12:18 PM
how do I maximise a window? drewsta Linux - Newbie 1 01-19-2004 10:06 PM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 11:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration