Skip to content

Commit

Permalink
First release.
Browse files Browse the repository at this point in the history
  • Loading branch information
n4ru committed May 4, 2018
1 parent a64f682 commit 01a6a83
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CopyDLLs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
copy %programdata%\Lenovo\ImController\Plugins\ThinkBatteryPlugin\x86\Lenovo.Modern.Portable.Battery.dll Lenovo.Modern.Portable.Battery.dll
copy %programdata%\Lenovo\ImController\Plugins\ThinkBatteryPlugin\x86\Plugins.Battery.Think.Native.dll Plugins.Battery.Think.Native.dll
34 changes: 34 additions & 0 deletions FakeSlice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Lenovo.Modern.Portable.Battery;
using Native;
using System;

namespace ThinkBattery
{
class Program
{

static void Main(string[] args)
{

var batInterface = new BatteryInterface();
var chargeStatus = batInterface.QueryBattery(1).SmartBatteryStatus.ChargeStatus.GetValue();
var bat = new ChargeThreshold
{
IsEnabled = true,
SlotNumber = 1,
StartValue = 0,
StopValue = 1
};
if (chargeStatus == "NoActivity") {
bat.StopValue = 0;
}
if (args.Length == 1 && args[0] == "on")
{
bat.StopValue = 1;
} else if (args.Length == 1 && args[0] == "off") {
bat.StopValue = 0;
}
batInterface.SetChargeThreshold(bat);
}
}
}
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# FakeSlice
Discharge USB-C Power Banks before internal battery on newer ThinkPads.
Discharge USB-C Power Banks instead of charging internal battery on newer ThinkPads, allowing them to function as a swappable "Slice Battery".

## Dependencies

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.

## Build

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.

## Run

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.

## To-Do

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 comments on commit 01a6a83

Please sign in to comment.