{"id":13598825,"url":"https://github.com/jdhitsolutions/PSClock","last_synced_at":"2025-04-10T10:30:26.183Z","repository":{"id":65753023,"uuid":"425245484","full_name":"jdhitsolutions/PSClock","owner":"jdhitsolutions","description":":watch: A set of PowerShell commands for creating and managing a transparent WPF-based clock that runs on your Windows desktop.","archived":false,"fork":false,"pushed_at":"2025-03-31T21:21:00.000Z","size":1191,"stargazers_count":35,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T07:52:58.113Z","etag":null,"topics":["powershell","wpf"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdhitsolutions.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2021-11-06T13:02:15.000Z","updated_at":"2025-03-31T21:21:01.000Z","dependencies_parsed_at":"2024-05-21T13:42:39.645Z","dependency_job_id":"5e884b08-0b9c-456a-a32c-0ce22fec8ecc","html_url":"https://github.com/jdhitsolutions/PSClock","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSClock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSClock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSClock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSClock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdhitsolutions","download_url":"https://codeload.github.com/jdhitsolutions/PSClock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199136,"owners_count":21063641,"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":["powershell","wpf"],"created_at":"2024-08-01T17:00:57.149Z","updated_at":"2025-04-10T10:30:26.174Z","avatar_url":"https://github.com/jdhitsolutions.png","language":"PowerShell","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"readme":"# PSClock\n\n![PSGallery Version](https://img.shields.io/powershellgallery/v/PSClock.png?style=for-the-badge\u0026logo=powershell\u0026label=PowerShell%20Gallery)![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/PSClock.png?style=for-the-badge\u0026label=Downloads)\n\n![logo](images/psclock.png)\n\nThis module will create a WPF-based clock, launched from a PowerShell prompt that on your Windows desktop. The clock runs in a background PowerShell runspace so that it doesn't block. The module will automatically clean up the runspace when you close the clock. You can customize the clock's appearance including how you want to format the date and time. The clock's background is transparent so all you see is formatted text.\n\n## Installation\n\nIf you are running Windows, you can install the module from the PowerShell Gallery. This module will work in Windows PowerShell and PowerShell 7 on Windows.\n\n```powershell\nInstall-PSResource PSClock [-scope AllUsers]\n```\n\nInstalling the module will also install the `Microsoft.PowerShell.ThreadJob` module if it isn't already installed. If you attempt to install the module with `Install-Module` and you have the legacy `ThreadJob` module installed, you might get a warning message. If this happens, run `Install-Module PSClock -AllowClobber`. This error doesn't seem to happen when using `Install-PSResource`.\n\n## Module Commands\n\n| Name                          | Alias       | Synopsis                                      |\n|-------------------------------|-------------|----------------------------------------------|\n| [Get-PrimaryDisplaySize](docs/Get-PrimaryDisplaySize.md) |             | Get the primary display size in pixels.      |\n| [Get-PSClock](docs/Get-PSClock.md)           | *gpc*       | Get PSClock details.                         |\n| [Save-PSClock](docs/Save-PSClock.md)         |             | Save current PSClock settings to a file.     |\n| [Set-PSClock](docs/Set-PSClock.md)           | *spc*       | Modify a running PSClock.                    |\n| [Show-FontPreview](docs/Show-FontPreview.md) |             | Show a font preview in a WPF form.           |\n| [Show-PSClockSettingPreview](docs/Show-PSClockSettingPreview.md) |             | Show a GUI preview of PSClock settings.      |\n| [Start-PSClock](docs/Start-PSClock.md)       | *psclock*   | Start a PSClock.                             |\n| [Stop-PSClock](docs/Stop-PSClock.md)         |             | Stop a running PSClock.                      |\n\n### [Start-PSClock](docs/Start-PSClock.md)\n\nUse `Start-PSClock` or the `psclock` alias to launch a PSClock.\n\n```powershell\nStart-PSClock -size 24 -FontFamily 'Bahnschrift Light'\n```\n\nThe font size must be at least 8. You should have tab completion for the `Color`, `FontFamily`, and other font-related parameters.\n\nBy default, the clock will be displayed on the center of your screen. You can click and drag the clock to reposition using the left mouse button. You might have to try a few times to \"grab\" the clock. You can close the clock with a right click or the `Stop-PSClock` command.\n\nThe command lets you specify any `DateTime` format string. This is the same value you would use in a command like `Get-Date -format U`. Note that these strings are case-sensitive. See https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings for more information.\n\n```powershell\nStart-PSClock -size 30 -Color Yellow -format G -FontFamily Verdana\n```\n\n![format G](images/sample-2.png)\n\n### [Save-PSClock](docs/Save-PSClock.md)\n\nYou can use `Save-PSClock` to export current clock settings to an XML file.\n\n```powershell\nSave-PSClock\n```\n\nThe file, `PSClockSettings.xml`, will be stored in `$HOME`. If the file is detected when you run `Start-PSClock`, the saved settings will be imported. If the file exists and you want to specify new settings, use the `-Force` parameter with `Start-PSClock`. This will not remove the saved settings file, only ignore it.\n\nYou need to manually delete the file if you no longer wish to use it. If you uninstall the module you will also need to manually delete the file.\n\n### [Get-PSClock](docs/Get-PSClock.md)\n\nUse this command to get information about the current clock.\n\n```cmd\nPS C:\\\u003e Get-PSClock\n\nRunning Format FontFamily Size Weight Color  Style  OnTop RunspaceID\n------- ------ ---------- ---- ------ -----  -----  ----- ----------\nTrue      G    Verdana      30 Normal Yellow Normal False         24\n```\n\nIf the clock is not running, the `Running` value will be displayed in Red and there will be no `RunspaceID`. There are other properties to this object you might want to use.\n\n```cmd\nStarted         : 3/30/2025 10:57:30 AM\nFormat          : G\nOutput          : 3/30/2025 10:59:49 AM\nRunning         : True\nFontFamily      : Verdana\nSize            : 30\nWeight          : Normal\nColor           : Yellow\nStyle           : Normal\nOnTop           : False\nCurrentPosition : {1729, 552}\nRunspaceID      : 24\n```\n\nThe `Output` property is a sample using the specified format string.\n\n### [Set-PSClock](docs/Set-PSClock.md)\n\nUse this command to modify the settings of a running PSClock.\n\n```powershell\nSet-PSClock -size 30 -color white -FontFamily 'Baskerville Old Face' -force\n```\n\n![modify the clock](images/sample-3.png)\n\nYou can also increase the size by selecting the clock and using the \u003ckbd\u003e+\u003c/kbd\u003e key. Decrease using the \u003ckbd\u003e-\u003c/kbd\u003e key. Each change takes a second to be applied. You might need to \"grab\" the clock and move it slightly to ensure you have it selected.\n\nIf you only want to change the color, you can use PSReadLine to display a formatted list of color options. After the `-Color` parameter, press \u003ckbd\u003eCtrl+Space\u003c/kbd\u003e and answer `Y`.\n\n![PSReadLine completion](images/set-psclock-color.png)\n\nMove the cursor to your selected choice and press \u003ckbd\u003eEnter\u003c/kbd\u003e.\n\n### Settings Preview Form\n\nVersion 1.4.0 updates the PSClock and allows you to configure the font family, style, and color via a WPF-based GUI. Select the clock and press `p` to display the form. The form elements have tooltips that explain each setting. Hover your mouse over the element to see the tooltip.\n\n![show settings preview](images/psclock-preview.png)\n\nYou can select a combination of font elements and view the preview. If you want to apply the new settings, click the `Apply` button. Don't forget to run `Save-PSClock` to save the settings if you want to re-use them the next time you start a clock.\n\nYou can also run `Show-PSClockSettingPreview`.\n\nIf you don't want to apply and changes, close the form.\n\n### [Stop-PSClock](docs/Stop-PSClock.md)\n\nUse this command to stop a running PSClock from the PowerShell prompt.\n\n```powershell\nStop-PSClock\n```\n\nYou can also right-click the clock to dismiss it, or close and remove the runspace it is using. You can still use `Get-PSClock` which should now reflect that a clock is not running.\n\n```cmd\nPS C:\\\u003e Get-PSClock\n\nRunning Format FontFamily           Size Weight Color Style  OnTop RunspaceID\n------- ------ ----------           ---- ------ ----- -----  ----- ----------\nFalse     G    Baskerville Old Face   30 Normal white Normal False\n```\n\n## Profile Integration\n\nIdeally, you will start and stop the PSClock from the PowerShell prompt. This ensures that the flag file is removed. When you terminate a PowerShell session with a running clock, the flag file will not be removed. One way to ensure that the clock is stopped is to add the following code to your PowerShell profile. This will remove the flag file when you end the PowerShell session.\n\n```powershell\nRegister-EngineEvent -SourceIdentifier PowerShell.Exiting -Action {\n    If ($PSClockSettings.Running) {\n        $flag = \"$ENV:temp\\psclock-flag.txt\"\n        If (Test-Path $flag) {\n            Remove-Item $flag -Force\n        }\n        Stop-PSClock\n    }\n} | Out-Null\n```\n\nHowever, this will only run if you type `exit` to terminate the session. If you simply close the window, the `PowerShell.Exiting` event will not be triggered. You can also add the code to your profile to automatically start the clock when you open a new PowerShell session. In Windows Terminal, you still might need to manually close the profile tab once you see that the clock has ended.\n\n## Runspaces and Limitations\n\nThe clock runs in a separate runspace launched from your PowerShell session. If you close the session, the clock will also be closed.\n\nThe command is designed to only have one clock running at a time. If you try to start another clock from another PowerShell session, you will get a warning.\n\n```cmd\nPS C:\\\u003e Start-PSClock\nWARNING:\nA running clock has been detected from another PowerShell session:\n\n[3/30/2025 11:00:36 AM] PSClock started by Jeff under PowerShell process id 46900\n\nIf this is incorrect, delete C:\\Users\\Jeff\\AppData\\Local\\Temp\\psclock-flag.txt and try again.\n\nDo you want to remove the flag file? Y/N:\n```\n\nIf you close PowerShell without properly shutting down the clock you may be left with the flag file. Delete the file and try again.\n\n## Font Preview\n\nThis module also includes a font preview utility. Run `Show-FontPreview` to display a WPF form that will let you preview different fonts.\n\n![font preview](images/show-fontpreview.png)\n\nYou can use the arrow keys or buttons to navigate through the fonts. Press \u003ckbd\u003eCtrl+Q\u003c/kbd\u003e to quit or manually close the form.\n\n## Module Design\n\nFor more details about the module design and technical implementation, read the [design document](Design.md).\n\n## Related Modules\n\nFor a WPF-based countdown timer, take a look at the [Start-PSCountdownTimer](https://bit.ly/3T5ntz1) command in the [PSTimers](https://github.com/jdhitsolutions/PSTimers) module.\n\n## Known Issues\n\nThere are no known issues at this time. Please post any bugs or feature requests in the [Issues](https://github.com/jdhitsolutions/PSClock/issues) section of this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2FPSClock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdhitsolutions%2FPSClock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2FPSClock/lists"}