Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

OS and Linux distribution support requests #4

Closed
25 of 39 tasks
Phundrak opened this issue May 2, 2021 · 7 comments
Closed
25 of 39 tasks

OS and Linux distribution support requests #4

Phundrak opened this issue May 2, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Phundrak
Copy link
Owner

Phundrak commented May 2, 2021

While #2 standardized the retrieval of the name of the running Linux distribution, eshell-info-banner.el has yet to support non-standard Linux distributions (such as GUIX) and non-Linux OSes, such as macOS and Windows.
Here will be listed Linux distributions and OSes not yet supported:

This list is subject to changes in the future, by shrinking or expanding.

@Phundrak Phundrak added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels May 2, 2021
@Phundrak Phundrak pinned this issue May 2, 2021
@bkaestner
Copy link
Contributor

You can use wmic for both partitions and memory:

wmic logicaldisk get Caption,Size,Freespace,Name,Filesystem /FORMAT:csv

Node,Caption,FileSystem,FreeSpace,Name,Size
BensPC,C:,NTFS,50240790528,C:,249083572224
BensPC,D:,NTFS,509776490496,D:,3000457228288

wmic os get TotalVisibleMemorySize, FreePhysicalMemory /FORMAT:csv

Node,FreePhysicalMemory,TotalVisibleMemorySize
BensPC,10777156,16706896

Unfortunately, wmic is both deprecated and somewhat unreliable: most calls take <30ms, but some take more than 5 seconds. Maybe someone else with more Windows knowledge can provide a better alternative. Feel free to ping me if you're still interested in an initial version based on wmic.

@bkaestner
Copy link
Contributor

bkaestner commented May 23, 2021

Unfortunately, wmic is both deprecated and somewhat unreliable

This might be my machine only, though. I have a network share mounted, but the server is offline. Windows still tries to reach it, check its properties, and times out after some seconds. This might also impede other solutions on other operating systems, e.g. nfs, sshfs or similar shares. That being said, if you only want to check the "usual" mounts, we can probably use Emacs' internal tools:

(defcustom eshell-info-banner-partition-windows-volumes
  (mapcar (lambda (x) (format "%c:" x)) (number-sequence ?C ?F))
  "Checked drive letters for volume measurements."
  :group 'eshell-info-banner
  :type '(repeat (string :tag "Volume letter")))

(defun windows-size-example ()
  "Returns a plist of the drives in `eshell-info-banner-partition-windows-volumes' with 
their respective sizes.

For every drive in the aforementioned variable, the resulting plist contains the 
following properties:

  label LABEL: the entry from `eshell-info-banner-partition-windows-volumes'
  free  BYTES: either the number of available bytes or nil
  size  BYTES: either the total disk size or nil on error

In order to format the bytes, you can use `file-size-human-readable-iec'."
  (mapcar (lambda (d)
            (let* ((info (file-system-info d))
                   (size (and info (nth 0 info)))
                   (free (and info (nth 1 info))))
              `(label ,d size ,size free ,free)))
          eshell-info-banner-partition-windows-volumes))

(mapconcat (lambda (x)
             (if (plist-get x 'size)
                 (format "Drive %s %s / %s\n"
                         (plist-get x 'label)
                         (file-size-human-readable-iec (plist-get x 'free))
                         (file-size-human-readable-iec (plist-get x 'size)))
               ""))             
           (windows-size-example)
           "")

The resulting string on the example above would be

Drive C: 46.5 GiB / 232 GiB
Drive D: 474.8 GiB / 2.7 TiB

Again, feel free to ping me if I should prepare a PR based on the solution above or wmic.

@Phundrak
Copy link
Owner Author

Phundrak commented Jun 14, 2021 via email

@Phundrak Phundrak self-assigned this Nov 6, 2021
@gopar
Copy link

gopar commented Nov 19, 2021

Looks like Mac os has versions 11.5 and 11.6. Seems like simple fixes to include in the list from the looks of it :)

@Phundrak
Copy link
Owner Author

Phundrak commented Nov 19, 2021 via email

@gopar
Copy link

gopar commented Nov 19, 2021

Still Big Sur :)
https://support.apple.com/en-us/HT211896

@Phundrak
Copy link
Owner Author

Phundrak commented Nov 19, 2021 via email

Repository owner locked and limited conversation to collaborators Dec 23, 2021
@Phundrak Phundrak converted this issue into discussion #16 Dec 23, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants