helloSystem / Utilities

Utilities written in PyQt5, meant for use with helloSystem
BSD 2-Clause "Simplified" License
28 stars 29 forks source link

Redesign some preferences #172

Open louies0623 opened 1 year ago

louies0623 commented 1 year ago

some design sketches

20230624_174428

20230624_174435

Hierosme commented 1 year ago

I have no trouble to remake the UI of Date and Time and use you template.

In general my source of insppiration is: https://flylib.com/books/en/2.585.1.237/1/

But i have really no trouble to use you template....

I just need a Go....

probonopd commented 1 year ago

Hi @Hierosme, thanks for chiming in.

https://flylib.com/ is great, but let's make it different enough so that it cannot be mistaken for a clone. It should be familiar but not the same. Also, let's always ask ourselves, can we make things even simpler/leave away options no one uses.

Hierosme commented 1 year ago

image

It have no Ok or Cancel button ... The apply button is the Toogled Lock/Unlock (Still in progress) I let the Help Button on buttom, because it reauire to creat our Own Tab widget for got it (I can do but take long time) The Clock got AM / PM management .

Enjoy ...

probonopd commented 1 year ago

The lock button is an unneeded complication. We can make it simpler by removing it.

probonopd commented 1 year ago

Also, let's move "Set date and time automatically" to the top, and have it checked by default.

If it is checked, then everything below it should be greyed out.

probonopd commented 1 year ago

"Custum Format" should be "Custom Format".

Hierosme commented 1 year ago

That is:

image

If it is checked, then everything below it should be greyed out. ---> That is on the read...

what about the Help button ?

probonopd commented 1 year ago

We don't have a Help, so we don't need a Help button for now.

Also, we don't need "Ok, "Cancel", "Apply". Everyhting should be applied immediately.

Hierosme commented 1 year ago

The Right Clock Tab is suppose to configure the global Menu Clock display on top/right of teh screen.

Have we a way to make it ? i just need a configuration file or i simply remove it ?

probonopd commented 1 year ago

Remove. Simplify.

Hierosme commented 1 year ago

Everyhting should be applied immediately.

That is the root cause of the loop asking password.

I have to investigate sudo fine setting for make it possible. globaly we should play with sudo timestamp_timeout but unfortunally that not the only thing to do...

A good approch consiste to ceate our own sudo policy . The /etc/sudoers.d/ is here for that. it will be really easy to impose on fly a any option for certain command, like Date and Time.

I can say NOPASSWORD by example but in fact all Sudoers policy can be apply , and a lot of documentation or best practive all ready exist.

Can i create a Date and Time.app sudoers policy ?

probonopd commented 1 year ago

That is the root cause of the loop asking password.

Do you know why that is?

As an alternative, we could run the whole peferences application with sudo -A -E - although it is not "nice".

Hierosme commented 1 year ago

I Think Yes, that the use of a subprocess child process The Child lost the parent and the sudo in that case destroy everything when quit.

That is explain on theat documentation: https://man.freebsd.org/cgi/man.cgi?sudoers(5)

You have to make the oposite and pass by the parent.

For example: It is possible to inform Sudouers about when a user start Date and Time it is automatically start with good permission if the user is part of Group X of Y. (Just a example).

In that case ENV var (timestamp informations) are preserved.

When you start a sub process child , Sudo start with a ultra short Env vars and by default destroy everything when exit .... Then normally the Timestamp sudo require to be in possition to impose the Env var to the child process.

BUT

When do it you have a ULTRA big security risk where the environement can permit to a bad user to jump ouside you SHELL and keep sudo permission.

The result we have is the default Sudo policy it not permit the actual code for Huge security risk ....

Hierosme commented 1 year ago

sudoers is not the best policy system of the world, but it is really reputate to work at all.

from it framework here how to:

Peprare a Alias command for permit apply a policy to they command alias. Prepare group/user for permit to appply a policy to they group/user Impose a poicy for the command.

The policy can be to ask the password, (Like what is done actually).

BUT now sudo know what to do globally and don't suppose to receive intructions from a subprocess child....

That method is static . It exist a aproch use by Samba team , where a Application generate dynamically all sudoers policy. Itś still static but it method Permit to fixe permission trouble for a Samba User. (The sudo trouble with Samba is a long story)

An other methos is to use a Sudoers Policy Manager Server , but really uncommon...

Hierosme commented 1 year ago

Here the part of the documenation it conserne our trouble:

sudoers uses per-user time  stamp files for credential caching.  Once a
     user has been authenticated, a record is written containing the user-ID
     that was used to authenticate, the terminal session ID, the start time of
     the session leader (or parent process) and a time stamp (using a mono-
     tonic clock if one is available).  The user may then use sudo without a
     password for a short period of time (5 minutes unless overridden by the
     timestamp_timeout option).  By default, sudoers uses a separate record
     for each terminal, which means that a user's login sessions are authenti-
     cated separately.  The timestamp_type option can be used to select the
     type of time stamp record sudoers will use.

The ultra important part : By default, sudoers uses a separate record for each terminal In that case terminal not mean QTerminal.app but Unix TERM, then in our case the TERM it have start teh session manager... Then impossible to start a subprocess child and conserve timestamp_timeout information inside the parent ....

Hierosme commented 1 year ago

OK i Got it.

depend of the case but sudo have Exactlly what we need for edit a file...

We should use sudoedit and our editor will be our app, by example Date and time.app is in fact a editor for /etc/ntpd.conf. (We inform /etc/sudoers.conf about that)

In that case that is Sudo is manage the user to work on a copy of the file to edit and only when apply Sudo will impose the security policy.

Then from documentation YES i got a good idea about how to... From Date and Time.app il have no code to do. I'll simply remove any call of Sudo, and create a sudoers policy ...

It will normally work like a charm, and that a big GO from security ppoint of view.

louies0623 commented 1 year ago

Mmm it is visually weird, is should be like this. I think. I'm sorry for my bad remarks. image

Supplement: Why is the arrangement of the calendar week so strange.

This would be more like what most people are familiar image

Hierosme commented 1 year ago

The calendar is simply the defautl widget setting.

The position of day depends of you Locales configuration, that mean here in France the first day of the week is Monday.

Normaly you havent to care about custom format, because all they rules are standard and impose by the configuration of Locales. On OsX it is done with International.app.

Here we are: When auto config is not set image

when it is set image

It have been long because AnalogClock widget have been monify for permit to be disabled.

louies0623 commented 1 year ago

image

"Use 24 hour clock" option should not be locked and red words of the locked calendar can be changed to dark gray. Below the date options, add these two options above the button. 5232-01-system-preferences-date

probonopd commented 1 year ago

Very nice but we need to get rid of the "Apply" button if possible.

louies0623 commented 1 year ago

I think the Help button is kept at the bottom, but it is locked, and then it says that this feature is under construction, at least. 『Correction of incorrect terms』

Hierosme commented 1 year ago

@probonopd Yes i'll remove the Apply button, at time i keep it for the Trigger, the time to provide a Sudoers policy for the Date and Time.app.

Normaly evrything about Sudo is correct, Date and Time.app will be a editor for /etc/timezone /etc/ntpdate.conf, and simply let the global Sudoers policy determine what have to be done.

@louies0623 Not trouble about bad remarks, bad or not a remarks is a start of a exchange. We working arround our exchange.

Actually it have no Tab for configure the Global Menu Clock. Option you asking for is not relatif to any configuration file. By example: Where the application is suppose to store the 24h clock setting ?

The original Date and Time.app provide the Global Menu widget (Docked), then all they options is store as setting of the global menu widget.

louies0623 commented 1 year ago

image I actually didn't think about this when I design.

Hierosme commented 1 year ago

I have no trouble to provide the Date widget for Global Menu... Then here all options you asking for will be use and functional.

image

The global menu can load a widget i can make it really .... we need a configuration file for store the setting but it will be user space. (No sudoers policy needed)

Hierosme commented 1 year ago

I just have confirm it work like a charm

export SUDO_EDITOR=./date_and_time.py; sudoedit /etc/timezone /etc/ntpd.conf

poooooooIt work. Now i can write on the two files, and havent to care about permissions...
That is the job to sudoedit to track modifications and use the Sudoers policy if needed ......

That is really a nice thing. And a super news for users. I put that line of code inside le Shell script it call date_and_time.py

Everything work like a charm

Hierosme commented 1 year ago

Look ntpdate will be remove from FreeBSD:

https://man.freebsd.org/cgi/man.cgi?query=ntpdate&sektion=8 (Inside the Note on the Top)

ntpd i a good value, but actually chrony is the boy...

can i consider edit a /etc/ntpd.conf file ?

probonopd commented 1 year ago

What change would be needed in that file? Would that be a static change that we can make one time in the ISO, or would that file be needed to be updated by your Python code?

Hierosme commented 1 year ago

ntpd can be use on a ISO Live launcher with the option ntp -q == ntpdate. In that case The clock is Set via CLI then a dedicated sudoers policy have to be create for it.

That is like ntpdate in that case only cron script make the job.

In True installer system the file is /etc/ntpd.conf, here the variable SUDO_EDITOR is use and the permission is done just for write inside /etc/timezone and /etc/ntpd.conf (Only if modification).

The sudoers policy is for permit to keep 15 minutes of sudo permission. Thr trick of SUDO_EDITOR is teh true way Sudo recommand to write on files.

The python SCript write nothing, by using the python script as a SUDO_EDITOR sudo create a copy of the file, and let the application write as it want on the copy. When save and modification have been done the sudoers policy is evaluate, and That Sudo if make teh write.

The Python script think about a write on a file but sudo overlap a copy of the file. Write/Read come from a copy ...

Hope i have well understand the question

Note: It work in both case because we true pass by the parent of the Application for get permissions.

Hierosme commented 1 year ago

Here the script i use as entry point for Date and Time.app

#!/bin/sh
HERE="$(dirname "$(readlink -f "${0}")")"
SUDO_EDITOR_TMP=$HERE | sed 's/\ /\\ /g'
export VISUAL="${SUDO_EDITOR_TMP}/Resources/date_and_time.py"
exec "sudoedit" "/etc/timezone" "/etc/ntpd.conf"

It depend of the sudoers policy, but the password is as only ask one time at start, and i keep the permision edit of the two files during 15 mns....

louies0623 commented 1 year ago

Can you test that it works fine at 640x480 (WVGA)? because it's the minimum screen requirement.If not then you add a scroll bar.

Hierosme commented 1 year ago

640x480 that a jurasic screen..

The Application got size 300x250.

I hav eonsidere the Tome Zone screen but i not understand why we can select more of one Time Zone ?

In fact normly a system got only one TimeZone configure and that setting is store under /etc/timezone or TZ Var. The Tab Time Zone you have as picture , look to be a TimeZone for display more of one Clock.

Not trouble to make you you describre, but like Clock infornation, whre the Application is supose tio Store they information ? Actually it have only one file /etc/timezone with only one line inside like "Europe/Paris"

In general by selection time zone, user got it type of screen. image

at first (Today). i'll make timezone work , with a ultra long list of TimeZone. second step will be to determine the type of presentation.

Clearly i dont know what to do with the design provided, it not look like a Time Zone selestion. It look like a multu clock system. (We can make it reality arroune the Global Menu Widget)

louies0623 commented 1 year ago

My design is that the first one is used as the main computer time zone, and the rest are used as other time zones that users want to see. image make it different from MacOS. link with this #169 feature

Hierosme commented 1 year ago

Yep that a Multi Clock tracking....

The provided design make fusion inside Date / Time / TimeZone and the Global Menu Widget. That will force the Application to have a config file for get memory of they settings.

A Backend of it type of software is done like that:

Date and time is critical for a computer, the TimeZone is not let to the choise user for a really good reason. Typically that is hightlly critical for FileSystem, Email, Certificats, User creation/expiration, Crhon, etc ..... if /etc/timezone require root permission that for good raison....

Then NO, Date Time / TimeZone is not a user choise, that a system choise .... The Global Nenu clock is use Space choise, YES .....

Do Application Date and Time is suppose to configure System Time ? if yes, we should be serious, some users know exactelly what the system is suppose to do.

if no then , The Date and Time is just a configuration for Global Widget Clock, and you should trust you hardware clock, because it will be the only one source...

It cant be have confusion.

System Space: /etc/timezone /etc/localtime /etc/ntpd.conf vars LC_* (each time impose by POSIX) /sbin/hwclock

User Space: Nothing, then we have to create Configuration file for store all that is not relative to system.

the OsX dialogs make exactlly the Job. Tab1: (System Only) Permit Administrator to set the Hardware Clock Manually Permit Administrator to sert teh Hardware Clock via NTP

Tab2:(System Only) Permit the Administrator to determine the Time Offset to add for get a Local Time value.

Tab3:(User Only) Permit User to set configuration about global Menu Clock Widget

The OsX design match with system configuration file, (Like GNOME or KDE)

TimeZone is a crucial standard, all ready define years and years ago: https://24timezones.com/timezone-map The goal is not to permit User to display Multi Clock, that is done for permit AirPlan Depart clock over the planet, GPS, etc....

I repeat the Multiclock or a Widget Global Menu setting , have nothng relatif with System Date and Time setting .... The basic of clock is teh Hardware Clock, that is ultra serious think. by example 100% of you CPU cycle == exactlly one sec.

Nothing arround system clock should be let to the user.

Hierosme commented 1 year ago

Hooo i forget , set the Date via CLI or TimeZone via TZ env var, are valid only ont the TERM it have init the session. If not, everything will be lost when close the Application (or Parent).

In that case what is suppose to be load by the Application at next startup ....

Hierosme commented 1 year ago

Here my plan:

Back to normal design (Clsoe to OsX) Stay simple as mush as possible Make it work Create the first Sudoers policy for User Friendly configuration style

In a second step : Investigate about the gloabl Menu Clock Create configuration file for the Global Menu Widget

With The knowledge of the two previus step: Fusion Global Menu Widget clock setting with Date Time / TimeZone for have a 2 Tabs applications. The goal of the last phase is to trash unused code or functionality (with less i do not work ...)

louies0623 commented 1 year ago

I slightly drew the actual size on a 640x480 screen, as shown in the picture, but 250x300 may be too small, because there are text buttons and icons, and the window must be at least 340x420. I'm thinking, if the preference setting in the future is not too special, the window will be 340x420 as the standard. hello somthing

Hierosme commented 1 year ago

Hoooo but you speack about convergence ?

Ok GNOME have converge just one year ago, it let us some marge.

Just for imagine what we speack about ... a simple Drag and drop with QDesigner with a Calendar Widget Take 375px Height.

No industrial after more of ten year of work have successfull convergence. Apple make two App one for IPhone and on other for Computer.

True Convergence is really recent. We can make a try, but that is not trivial at all.

https://puri.sm/posts/true-convergence-is-here-pureos-10-is-released-for-all-librem-products/

What you describ have never exist by the past...

probonopd commented 1 year ago

helloSystem is made for desktop/notebook computers operated by precision pointing devices like a mouse. Not for "convergence" operated by fingers/pens/whatever.

Hierosme commented 1 year ago

It have no effect Finger or Cursor from Qt point of view.

The Technical challenge of convergence is HDPI on ultra small screen. Here is the rock ....

From application , that consit to estimate the size allowed and change the Layout on fly ... The trouble is clearly the need of hight level lib. Qt is OK but it will force us to have helloSystem Lib dedicated to the convergence...

From my point Convergence is a True Challenge with Qt, Yes i'm old Dev but Qt is a bit new for me. To be franc I'm not sure to have the require skill to make it reality...

I 'll do my best for keep Application tiny and maintainable .

Then i cn consider 640x480 as our Maximal size ?

probonopd commented 1 year ago

From my point Convergence is a True Challenge with Qt, Yes i'm old Dev but Qt is a bit new for me. To be franc I'm not sure to have the require skill to make it reality...

Convergence is a compromise everywhere. Let's not even have it as a goal for helloSystem.

Then i cn consider 640x480 as our Maximal size ?

The smallest supported screen size for helloSystem is 800x600. The application must be somewhat smaller to fit in there with the Menu and everything.

louies0623 commented 1 year ago

I don't mean fusion, but it means that there is a screen with this screen resolution size. image keep it" because there are still screens of this size. https://www.reddit.com/r/linux_gaming/comments/9bza2e/playing_doom_2016_at_640x480_on_a_crt/

image

Hierosme commented 1 year ago

I suggest to keep" because there are still screens of this size.

With a screenshoot of a CRT screen .... LOL that was one of my first sreen

Why not the Raspberry Pi Touch Display it have a 800x480 resolution Haaaaaaaaaaaaaaaaaaa ?

i joke ...

louies0623 commented 1 year ago

At least it is still alive and well, and some people are using it, and this is not a screenshot. https://www.reddit.com/r/vintagecomputing/comments/h7lsjk/is_there_a_way_to_make_the_window_fit_the_whole/

louies0623 commented 1 year ago

"VGA debuted with 640x480 pixels and 16 or 256 colors. This is still the mode PCs boot into, and it is also used in Safe Mode with the display driver disabled (in case the driver is the problem)."

https://www.pcmag.com/encyclopedia/term/vga

Hierosme commented 1 year ago

I try to create a TimeZone world map widget , just for fun a screenshoot image

Hierosme commented 1 year ago

image

This is greenwich location :+1:

louies0623 commented 1 year ago

World Map HDcolor_工作區域 1 I hope to use a satellite image, this is what I did when I was bored, I hope to be able to use it. CC0

Hierosme commented 1 year ago

image

The mouse over work

I'll use you texture soon

louies0623 commented 1 year ago

I adjusted the map to match the one used for this image. World Map HDcolor fix.jpg.zip image image

Hierosme commented 1 year ago

image

I have make a error in my design.

after just have do add The Grid Size x by the time zone from UTC start point of stop point ....

BUT The earth is round and the time zone is more like that image

You can see the error when is select UTC+1 Paris is out of the TimeZone.... , you can see it on my screen shoot

By design what i have try will not work...

The trouble is a true coordinate location x / y, it use tge IANA db store on /usr/local/zoneinfo/zone1970.tab

With a true relaction mouse position / map pixel_to_coordonates then everything will work as we want

That is not really hard to do that just a 360 / image.width and 360/ image.heigth. And by design more it got pixel more it is OK.

I hope got the IANA db import soon The widget View is here no trouble, the widget have every feature require for be a data source for the rest of the Application. (Got selection memory, Got mouse over, Information line if know where put the text, Totaly elastic, On fly load image with defferent resolution, etc ....)

Regards