Comments (8)
Looking at the Battery segment, it could be interesting to attach the logic there.
The main thing would be investigating how this works across operating systems. Looks like a creating a POC for Windows, but I could imagine something where you pass in a list within the omp.json
of what you want to monitor, GIVEN there is some standardized way to query peripherals and their status.
@Marc013 would you be interesting in creating something using the Command segment that could theoretically handle this?
from oh-my-posh.
@ivan-the-terrible I feel this is a very specific use-case for now which would justify the use of Set-PoshContext and create multiple environment variables to add that context to and use in a text segment's template
.
from oh-my-posh.
@JanDeDobbeleer oh nice! Yeah this would be a perfect use case for leveraging the template.
from oh-my-posh.
@ivan-the-terrible implementing this natively would also require finding the right syscall on Windows which is always a little challenging. There be dragons.
@Marc013 Can you proceed with my proposal above, or do you need a more elaborate sample?
from oh-my-posh.
@JanDeDobbeleer and @ivan-the-terrible ,
Thank you very much for you your quick response.
The purpose is to check the battery status of Bluetooth devices. In my opinion, this is a common use case as more and more devices are connected to Bluetooth.
Nevertheless, I tried the suggested Set-PoshContext solution.
Unfortunately, this is not an option because the pwsh command takes more than 1.5 seconds to execute, so the prompt is extremely delayed.
from oh-my-posh.
@Marc013 chances are this will take the same amount of time using golang (if I can find out how) as the underlying syscall
will be identical.
from oh-my-posh.
Thank you for informing.
I will try to come up with an alternate solution.
from oh-my-posh.
@Marc013 you could run a scriptblock
to assign the env vars (didn't test this):
$scriptblock = {
$env:MOUSE_BATTERY_LEVEL = (Get-PnpDevice -Class Bluetooth -FriendlyName 'MX Master 3' | Get-PnpDeviceProperty -KeyName '{104EA319-6EE2-4701-BD47-8DDBF425BBE5} 2').Data
$env:KEYBOARD_BATTERY_LEVEL = (Get-PnpDevice -Class Bluetooth -FriendlyName 'Keychron K3 Max' | Get-PnpDeviceProperty -KeyName '{104EA319-6EE2-4701-BD47-8DDBF425BBE5} 2').Data
}
function Set-BatteryLevels {
Start-job -ScriptBlock $scriptblock
}
New-Alias -Name 'Set-PoshContext' -Value 'Set-BatteryLevels' -Scope Global -Force
from oh-my-posh.
Related Issues (20)
- git-bash + win11 terminal = corrupted history HOT 5
- Unicode symbols in prompt HOT 5
- Linux OS labels can't be customized when `display_distro_name` is `true` HOT 2
- Transparent is not worked with Window Terminal enabling aryclic material HOT 1
- oh-my-posh and VSCode 1.90 terminal change conflicts HOT 1
- Adds a `max_length` property to the style "Agnoster Short" of "Path" segments HOT 1
- When I open the git repository of the Java project, some things seem to have some issues. HOT 12
- Broken prompt on vscode terminal HOT 3
- Right side of of theme isn't displayed correctly in VSCode HOT 1
- Website dependencies do not include `react-router-dom` for pnpm HOT 3
- Python virtual environment displaying even if deactivated
- Version 21.3.0 is not usable with VScode HOT 4
- Weird phenomenon in VSCode Terminal HOT 11
- Add more issue templates HOT 1
- Git segment shows (detached) when using .Ref template property if the current commit is tagged
- Refresh Git widgets periodically HOT 6
- Linux change Font dir
- Improve `Dotnet` segment HOT 3
- Route /docs/auth seems to be broken
- Conditional powerline/diamond symbols
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oh-my-posh.