Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class OS: Implement funcs for fetching distribution name and version #5022

Closed
MJacred opened this issue Jul 30, 2022 · 4 comments
Closed

class OS: Implement funcs for fetching distribution name and version #5022

MJacred opened this issue Jul 30, 2022 · 4 comments
Milestone

Comments

@MJacred
Copy link

MJacred commented Jul 30, 2022

Describe the project you are working on

Videogame - features bug reporting, therefore requires collecting system info

Describe the problem or limitation you are having in your project

  • get_name returns for Linux and BSD systems X11 (in Godot 3) or linuxbsd (in Godot 4), but not a better fitting value such as the distribution name
  • cannot get OS version to narrow down issues to specific OS versions

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Picking up on godotengine/godot#31895

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

new funcs

  • OS.get_version() String
  • OS.get_distribution_name() String

Add OS.get_distribution_name for Linux and BSD

This func returns for Linux and BSD the value X11 in Godot 3, linuxbsd in Godot 4.
Even the name change in Godot 4 basically only lists the OS family name (joined together). But these families have many members, which do their own thing: Ubuntu, Manjaro, OpenBSD, etc.

Therefore, there is the suggestion to add a OS.get_distribution_name() func, which returns values such as

  • Ubuntu, Mageaia, Manjaro, Ubuntu, Linux Mint, Arch Linux, Linux Mint etc. (i.e. distribution names for Linux OS family)
  • OpenBSD, FreeBSD, etc. (i.e. distribution names for BSD OS family)

Proposed API func description:

String get_distribution_name ( ) const
# Returns on Linux and BSD platforms the user OS' distribution name (e.g. Ubuntu, Manjaro, OpenBSD, etc.). For other platforms, the OS name is returned.

Add OS.get_version

String get_version ( ) const
# Returns the OS' actual technical version number and not its user-friendly version used in marketing. This helps distinguishing between minor versions or even insider and custom builds.
# For Windows this returns e.g. version `10.0.9926` instead of `10`, and `6.0…` instead of the marketed version `Vista`.
# For rolling distributions, such as Arch Linux, it returns an empty String.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Cannot be worked around with a few lines. Would require system calls which are OS-specific.

Is there a reason why this should be core and not an add-on in the asset library?

This is about improving collecting system info for video games, apps and Godot itself (at least giving Godot the potential to copy&paste system data in github issues - which should be approached in a separate proposal).

@MJacred MJacred changed the title Improve OS.get_name() and implement OS.get_version() Improve OS.get_name() and implement funcs for fetching distribution and version info Jul 30, 2022
@Calinou
Copy link
Member

Calinou commented Jul 30, 2022

get_name() returns values such as

No, I don't think OS.get_name() should return anything but the name of the platform Godot was compiled for. A lot of people rely on the existing behavior. Most of the time, you don't care which Linux distribution is used to run Godot – it's built in a way to abstract those differences as much as possible.

There could be OS.get_distribution_name()1 and OS.get_version() methods, but I wouldn't go any further. As for getting the display server's name, this should be DisplayServer.get_name() instead 🙂

On Windows, it's also debatable whether OS.get_version() should return the "user-friendly" version number (7, 8, 10, …) or the actual version number (6.1, 6.2, 10.0, …). For example, opening a command prompt will display the actual Windows version number.
I would prefer getting the actual version number as its long form will also let you know the Windows build number. This lets you distinguish between various Windows 10/11 feature upgrades and whether the user is on an Insiders build.

This func returns for linux the value X11,

The X11 platform was renamed to linuxbsd in 4.0, as part of the OS/DisplayServer split. This can't be backported to 3.x for compatibility reasons.

This func returns for macOS the value OSX. Since 2016 it's called macOS, so it would be prudent to update that name.

The OSX platform was recently renamed to macOS in 4.0. This also can't be backported to 3.x for compatibility reasons.

Footnotes

  1. On non-Linux platforms, OS.get_distribution_name() should probably return the OS' name.

@Calinou Calinou added the breaks compat Proposal will inevitably break compatibility label Jul 30, 2022
@Calinou Calinou added this to the 4.0 milestone Jul 30, 2022
@MJacred
Copy link
Author

MJacred commented Jul 30, 2022

I find your mentions and suggestions totally fine.

For Windows, I'd also prefer the actual version numbers.

EDIT: If we go with your suggestions, then there should be no breaks compat. I'll clean up the proposal tomorrow.

@MJacred
Copy link
Author

MJacred commented Jul 31, 2022

@Calinou: ok, I finished rewriting the proposal. It should not break compatibility now.

@MJacred MJacred changed the title Improve OS.get_name() and implement funcs for fetching distribution and version info class OS: Implement funcs for fetching distribution name and version Jul 31, 2022
@Calinou Calinou removed the breaks compat Proposal will inevitably break compatibility label Jul 31, 2022
@akien-mga
Copy link
Member

Implemented by godotengine/godot#65525.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants