Need script that launches display of /mnt/home and moves it to a spot on desktop. Adjusting for desktop size (Solved)

New to Puppy and have questions? Start here

Moderator: Forum moderators

Post Reply
User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

Need script that launches display of /mnt/home and moves it to a spot on desktop. Adjusting for desktop size (Solved)

Post by theroar84 »

I want a script that launches the /mnt/home location (drive partition) and moves it to a spot on my desktop. Currently I modify the script for pc's with different monitor sizes/desktops.

#!/bin/bash
rox -d /mnt/home
xdotool search " */mnt/home" windowactivate windowsize %@ 200 600 windowmove 1150 30

I would love to have a variable X for the window move and a way to detect the desktop size.
Then if the desktop is 1280x1012 X would = 1150
If it were larger than 1280 it would be 1350

Any tips for making that work?

It is not that much code to alter between machines, but if I understood how to make scripts smarter using that desktop size I think it would be slick.

Thanks again for your time.

Last edited by bigpup on Fri Jun 21, 2024 7:44 pm, edited 2 times in total.

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

User avatar
MochiMoppel
Posts: 1196
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 20 times
Been thanked: 415 times

Re: Smart Script based on Desktop Size?

Post by MochiMoppel »

Try

Code: Select all

#! /bin/sh
rox -d /mnt/home

WINDOWWIDTH=400  #width  of ROX window
WINDOWHEIGHT=600 #height of ROX window
WINDOWY=30       #margin from top screen edge
RIGHTMARGIN=50   #margin from right screen edge

ARRAY=($(xwininfo -root))
SCREENWIDTH=${ARRAY[27]}
WINDOWX=$((SCREENWIDTH-WINDOWWIDTH-RIGHTMARGIN))

xdotool getactivewindow windowsize $WINDOWWIDTH $WINDOWHEIGHT windowmove $WINDOWX $WINDOWY

I changed your xdotool command because it would also affect any already existing /mnt/home windows and may switch to the last desktop where such windows exist. Probably not what you want. Also I couldn't persuade xdotool to make a ROX window narrower than the specified minimum size of 236, so 200 as in your example seems impossible (at least with xdotool).

Using wmctrl instead of xdotool :

Code: Select all

wmctrl -r :ACTIVE: -e 0,$WINDOWX,$WINDOWY,$WINDOWWIDTH,$WINDOWHEIGHT

BTW: New topic title "Need script that locates icon based on desktop size" makes no sense. "locates"? "icon"?
To the moderator who changed the title: Please read the topic carefully before making changes :roll:

User avatar
Flash
Moderator
Posts: 954
Joined: Tue Dec 03, 2019 3:13 pm
Location: Arizona, U.S.
Has thanked: 50 times
Been thanked: 119 times

Re: Need script that locates icon based on desktop size

Post by Flash »

@MochiMoppel, I did read the topic and it seemed to ask how to have an icon located in the same place (in relation to the other icons on the screen) no matter what size display was used. How would you word the subject line so it makes sense to the average Puppy user?

Chaos coordinator :?
User avatar
bigpup
Moderator
Posts: 6836
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 874 times
Been thanked: 1471 times

Re: Need script that launches display of /mnt/home and moves it to a spot on desktop. Adjusting for desktop size

Post by bigpup »

I tried a edit to the topic subject.

So, see if it is better now.

------------------------------------------------------------------------------------------------------------------------------
One thing to understand.

There are two home locations in Puppy Linux.

/mnt/home is not a directory.

It is a location mount point, added to the operating file system, when a save file/folder is made, and booted using the save.
It is not present until a save is made and booted using it.

It mounts the partition the save is stored on, so the save can be read from and written to.
This is a mount that cannot be unmounted.

Usually /mnt/home is also the partition the other Puppy files are on.
However, if the save is on a different partition or partition on a different drive, that is not the same location as the other Puppy files.
The save location is still /mnt/home

Clicking on /mnt/home, opens a Rox window showing the contents of the partition, the save is stored on.

The actual home directory in the file system.
Is /home
In Puppy this is the home directory for spot restricted user and the spot directory location.
That is all it is used for.

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

User avatar
mikewalsh
Moderator
Posts: 6034
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 738 times
Been thanked: 1899 times

Re: Need script that launches display of /mnt/home and moves it to a spot on desktop. Adjusting for desktop size

Post by mikewalsh »

@theroar84 :-

To add to m'colleague's points above, technically /mnt/home is a sym-link to

Code: Select all

/initrd/mnt/dev_save

.....and /mnt/home is a location in the filesystem totally unique to Puppy. You'll not find this on ANY 'mainstream' distro that uses the traditional 'full' install (requiring a dedicated partition all to itself), since it's all to do with the layered file-system used by your average Puppy.

/Mnt/home is the location of the Puppy 'system' files, in one of the 'layers' of the file-system stack (as bigpup quite rightly says, this location does not in fact exist until the moment a 'save' is created at first 'shut-down'.....except as locations in the 'virtual' file-system in RAM where our Pup runs for the duration of a session).....along with pup_ro2, pup_ro3, pup_ro4, etc.

These are read-only 'layers' (hence, 'ro'); I'm no expert with this stuff, and am happy to be corrected, but as I understand it these latter are individually assigned to things like the 'alphabet' drvs, firmware SFSs, the kernel (??? - not sure about this one), and/or any other SFS packages the individual may decide to 'load'......in other words, every SFS package has its own individual layer in the system (probably assigned as part of the SFS 'on-the-fly' loading mechanism).

pup_rw also resides at this same level; this is the 'save' itself - the one part of the stack that is not just readable but ALSO 'writeable' (hence, 'rw')..

I believe the term '/mnt/home' was chosen mainly because it's an easier-to-understand, 'human-friendly' label that people can get their heads around more readily......it is, after all, the 'home' of the highly-compressed system files, the very items that go to make up the marvellous & highly-unique creation known as a 'Puppy'! The average user doesn't need to know about all the different layers that are used in said construction; indeed, the sole fact that most are interested in is that once everything is re-combined, what John Doe 'sees' & interacts with on his screen is no different to what you would expect to see with any other Linux distro.

(If any user IS interested in the tech-specs, mechanics & the 'nitty-gritty' of Puppy's operation, we have plenty of members who are more than willing to accommodate you!)

I just felt a bit more detail wouldn't go amiss at this point..... :roll: :D

Mike. ;)

User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

Re: Need script that launches display of /mnt/home and moves it to a spot on desktop. Adjusting for desktop size

Post by theroar84 »

Thanks so much for the scripts and tips! I have no idea what I was thinking with how I first titled the post. Thanks for cleaning that up as well.

I like the options with the code. It is very possible the script I had is stopping at 236 and I just could not tell the difference... 🤦‍♂️

Thanks again Everyone and have a great week!

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

Re: Smart Script based on Desktop Size?

Post by theroar84 »

This code worked great. You were spot on about rox not being able to go to 200... turns out all I was doing to get the result I wanted was to move the window so far to the right that I had the 200 pixels I wanted visible. I swapped the rightmargin 50 with a -150 and it works perfectly.

The line ARRAY=($(xwininfo -root))... Are you building an array with the info above, or is xwininfo a built in function. Thanks again for all the help!

MochiMoppel wrote: Fri Jun 21, 2024 3:37 am

Try

Code: Select all

#! /bin/sh
rox -d /mnt/home

WINDOWWIDTH=400  #width  of ROX window
WINDOWHEIGHT=600 #height of ROX window
WINDOWY=30       #margin from top screen edge
RIGHTMARGIN=50   #margin from right screen edge

ARRAY=($(xwininfo -root))
SCREENWIDTH=${ARRAY[27]}
WINDOWX=$((SCREENWIDTH-WINDOWWIDTH-RIGHTMARGIN))

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

User avatar
MochiMoppel
Posts: 1196
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 20 times
Been thanked: 415 times

Re: Smart Script based on Desktop Size

Post by MochiMoppel »

@theroar84
Glad to hear that it works, but what is your reason to shift part of the window outside of the visible area?

theroar84 wrote: Sun Jun 23, 2024 2:04 pm

The line ARRAY=($(xwininfo -root))... Are you building an array with the info above, or is xwininfo a built in function.

xwininfo is not an internal function, it is an external command. If you run xwininfo -root from a command line you will see that it gives you information about the root window, the "mother of all windows" that always has the same dimension as your screen. The ARRAY in my code example holds the output of this command in an array. The 27th array element, i.e. word in the output, (it counts from 0) happens to be the value for the width.

There are many other tools and ways to retrieve the screen dimension. I used xwininfo with an array because it's fast and one of the shortest codes I know. If you prefer to stay with xdotool you could use something like this:

Code: Select all

GEOMETRY=$(xdotool getdisplaygeometry)
SCREENWIDTH=${GEOMETRY% *}

You now have all the ingredients to place not only one, but two ROX windows sid-by-side and create your own poor man's dual-pane window manager. Good luck :thumbup2:

User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

Re: Need script that launches display of /mnt/home and moves it to a spot on desktop. Adjusting for desktop size

Post by theroar84 »

Thanks for explaining it. 👍 Makes sense now. With my lack of knowledge, but willingness to guess and check, I can get a ways... but I am always missing the building blocks.

My reason for pushing that window so far to the right has to do with screen real estate. I have several scripts stored in home that I run to make the mouse do some silly xdotool clicking wizardry. =) The monitor on the old pc is 1280 x 1024, so by having that window way right it does not interfere with my clicks, but it has enough space that I can click on the correct script when I need it.

It would likely be smarter to make a tool bar with an app to run my scripts, but this works and is so easy to update.

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

Post Reply

Return to “Beginners Help”