{"id":16971742,"url":"https://github.com/juancarlospaco/nim-osutil","last_synced_at":"2026-03-16T02:34:09.465Z","repository":{"id":151515569,"uuid":"132552305","full_name":"juancarlospaco/nim-osutil","owner":"juancarlospaco","description":"OS Utils for Nim, simple tiny but useful procs for OS.","archived":false,"fork":false,"pushed_at":"2018-07-29T07:23:40.000Z","size":39,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-26T14:48:40.698Z","etag":null,"topics":["battery","nim","nim-lang","operating-system","process"],"latest_commit_sha":null,"homepage":null,"language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juancarlospaco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-08T04:08:26.000Z","updated_at":"2023-08-13T03:39:01.000Z","dependencies_parsed_at":"2023-05-18T21:45:50.135Z","dependency_job_id":null,"html_url":"https://github.com/juancarlospaco/nim-osutil","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fnim-osutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fnim-osutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fnim-osutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fnim-osutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juancarlospaco","download_url":"https://codeload.github.com/juancarlospaco/nim-osutil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244860611,"owners_count":20522466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["battery","nim","nim-lang","operating-system","process"],"created_at":"2024-10-14T00:54:19.586Z","updated_at":"2026-03-16T02:34:09.421Z","avatar_url":"https://github.com/juancarlospaco.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nim-os-util\n\n- This module is Linux-only.\n- `at` wrapper for Nim.\n- `cpulimit` wrapper for Nim.\n- `ionice` wrapper for Nim.\n- `xset` wrapper for Nim.\n\n\n![screenshot](https://github.com/juancarlospaco/nim-osutil/raw/master/temp.png)\n\n\n# Use\n\n```nim\n\u003e\u003e\u003e import osutil\n\u003e\u003e\u003e echo set_process_name(\"MyAwesomeNimApp\")\n\u003e\u003e\u003e discard set_process_cpu_limit(50) # Max CPU usage 50%, 5%~100% is valid.\n\u003e\u003e\u003e echo set_process_ionice()         # Max I/O usage class 3, 0~3 is valid.\n\u003e\u003e\u003e echo at(\"midnight\", \"/bin/free\")  # Free at Midnight, as Job 1. Poor mans AT wrapper for Nim.\n\u003e\u003e\u003e echo atq()                        # Lists all AT Jobs with number ID from queue.\n\u003e\u003e\u003e echo atrm(1)                      # Removes Job 1 from job queue.\n\u003e\u003e\u003e echo set_display_off()            # Turn OFF monitor display.\n```\n\n\n# Install\n\n```\nnimble install osutil\n```\n\n\n# Requisites\n\n- `cpulimit` (Linux Package)\n- `ionice` (Linux Package)\n- `xset` (Linux Package)\n- `at` (Linux Package)\n\n\n# Documentation\n\n- If something is missing from Docs check the source code, its executable by itself.\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eset_process_name(\"SomeName\")\u003c/b\u003e\u003c/summary\u003e\n\n**Description:**\nSet the current Process name in Nim, shows up on system monitor with custom name.\n\nIf you dont set the process name it will show up as `\"nim\"` or `\"main\"` or\nthe filename of the main executable.\n\nFor SysAdmins and DevOps is important to quickly identify a particular process on\nthe system monitor, that can be a GUI or a command like `htop` or `glances`.\n\nGiving a proper name to your processes makes your software feel more professional.\n\nUses a low level call to `libc.so`. **Only available on Linux.**\n\n**Arguments:**\n- `name` A Name for your Process, `string` type, required.\n\n**Returns:** None.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eset_process_cpu_limit(limit)\u003c/b\u003e\u003c/summary\u003e\n\n**Description:**\nSet the current Process CPU Usage Limit cap from 5% to 100% on global percentage.\n\n`5` ~ `100` is valid. 100% makes almost no effect.\n\nThis is designed for background unimportant stuff, do not use on user-facing GUI!.\n\nIt starts a child sub-process that will cap the main process, when main process ends so does the sub-process.\n\nWith this you can trade speed for lower CPU resource usage, for example you can extend battery life on mobile devices by doing so.\n\nUses `cpulimit` **Only available on Linux.**\n\n**Arguments:**\n- `limit` A Limit on CPU Usage on Percentage for your Process, global percentage for all CPU Cores,\n`range[5..100]` type, defaults to `5` which means 5% CPU max, required.\n\n**Returns:** `Process`.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eset_process_ionice(scheduling_class)\u003c/b\u003e\u003c/summary\u003e\n\n**Description:**\nSet the current Process I/O Usage Limit cap from \"Idle\" to \"Real-Time\".\n\nIts similar to https://nim-lang.org/docs/posix.html#nice,cint but for I/O.\n\n`0` ~ `3` is valid. `2` makes no effect. This may delay I/O Operations to disk.\n\n`0` is `none`, `1` is `RealTime`, `2` is `best-effort` (Default), `3` is `idle`.\n\nThe default of all systems is `2`, `best-effort`.\n\nThis is designed for background unimportant stuff, do not use on user-facing GUI!.\n\nWith this you can trade speed for lower I/O resource usage, for example you can extend battery life on mobile devices by doing so.\n\nUses `ionice` **Only available on Linux.**\n\n**Arguments:**\n- `scheduling_class` A Limit on I/O Usage for your Process,\n`range[0..3]` type, defaults to `3` which means `idle`, `idle` means use I/O when idle, required.\n\n**Returns:** `tuple[output: TaintedString, exitCode: int]`.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eset_display_off()\u003c/b\u003e\u003c/summary\u003e\n\n**Description:**\nTurn Display Off using Nim, crossplatform, 1 proc, turns off monitor,\ndesigned for long running tasks on mobile devices.\n\n**Arguments:** None.\n\n**Returns:** `tuple[output: TaintedString, exitCode: int]`.\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuancarlospaco%2Fnim-osutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuancarlospaco%2Fnim-osutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuancarlospaco%2Fnim-osutil/lists"}