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)
- Ability to not process the command in `command`
- I always lost my customize when I open the new tab HOT 1
- The git segment doesn't render correctly when switching to a shorter branch name HOT 6
- plugin system like "oh-my-zsh" HOT 1
- python segment not working
- Firebase segment does not work on child folders HOT 2
- Line wrapping the time to 2nd line HOT 4
- Loss of appearance when resizing window HOT 1
- Difference between JSON themes schema and documentation HOT 1
- New segment request: Talosctl current context HOT 6
- Improve performance for git prompts (on PowerShell) HOT 6
- shell config error
- When using nushell with --no-history I get error on oh-my-posh.nu HOT 8
- Long command from history disappears during attempt to modification (for slimfat theme)
- Weird escape characters on the VSCode integrated Terminal HOT 14
- git {{ .BranchStatus }} reports as ≢ even with upstream
- Disabling update checks from the configuration file
- Color is not rendered randomly HOT 1
- Unexpected error icon on WSL startup HOT 1
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.