Skip to content

Commit 01a6a83

Browse files
committed
First release.
1 parent a64f682 commit 01a6a83

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

CopyDLLs.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
copy %programdata%\Lenovo\ImController\Plugins\ThinkBatteryPlugin\x86\Lenovo.Modern.Portable.Battery.dll Lenovo.Modern.Portable.Battery.dll
2+
copy %programdata%\Lenovo\ImController\Plugins\ThinkBatteryPlugin\x86\Plugins.Battery.Think.Native.dll Plugins.Battery.Think.Native.dll

FakeSlice.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Lenovo.Modern.Portable.Battery;
2+
using Native;
3+
using System;
4+
5+
namespace ThinkBattery
6+
{
7+
class Program
8+
{
9+
10+
static void Main(string[] args)
11+
{
12+
13+
var batInterface = new BatteryInterface();
14+
var chargeStatus = batInterface.QueryBattery(1).SmartBatteryStatus.ChargeStatus.GetValue();
15+
var bat = new ChargeThreshold
16+
{
17+
IsEnabled = true,
18+
SlotNumber = 1,
19+
StartValue = 0,
20+
StopValue = 1
21+
};
22+
if (chargeStatus == "NoActivity") {
23+
bat.StopValue = 0;
24+
}
25+
if (args.Length == 1 && args[0] == "on")
26+
{
27+
bat.StopValue = 1;
28+
} else if (args.Length == 1 && args[0] == "off") {
29+
bat.StopValue = 0;
30+
}
31+
batInterface.SetChargeThreshold(bat);
32+
}
33+
}
34+
}

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
# FakeSlice
2-
Discharge USB-C Power Banks before internal battery on newer ThinkPads.
2+
Discharge USB-C Power Banks instead of charging internal battery on newer ThinkPads, allowing them to function as a swappable "Slice Battery".
3+
4+
## Dependencies
5+
6+
This application requires Lenovo Vantage to be installed, but doesn't require you to have it running. More specifically, the System Interface Package that comes bundled with Lenovo Vantage is required. You will also need two specific DLLs that come with the application. Since these files are proprietary code, they cannot be included. However, the included `CopyDLLs.bat` script should copy the dependencies from their default installation location to the directory it is ran from.
7+
8+
## Build
9+
10+
Just throw `FakeSlice.cs` into your favorite C# compiler, target .NET Framework 4.5, and add the two required references - `Plugins.Battery.Think.Native.dll` & `Lenovo.Modern.Portable.Battery.dll`, then compile as Windows Application.
11+
12+
## Run
13+
14+
The included release binary will toggle your setting when launched without any commandline arguments. Running the application with the argument `on` will turn the FakeSlice "on" - which will disable charging and run off your Power Bank. Running the application with the argument `off` will turn the FakeSlice "off" and charge the internal battery. This should allow you to use FakeSlice in your scripts with ease, and without any arguments FakeSlice works great when bound to a hotkey (ike `Fn + F12`) using Lenovo Vantage.
15+
16+
## To-Do
17+
18+
Fakeslice currently only supports single battery ThinkPads. Support for Power Bridge enabled systems should be coming in a few days, which will allow you to disable internal battery charging. The current version will only disable charging the battery internally marked as the primary.

0 commit comments

Comments
 (0)