Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,9 @@ install(
DESTINATION share/licenses/${PROJECT_NAME}
COMPONENT documentation
)

install(
FILES oshot.desktop
DESTINATION share/applications
COMPONENT documentation
)
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@ If when starting oshot, it starts to flick a screen black (or it won't launch),

If still errors, please open an [Issue](https://github.com/Toni500github/oshot/issues) and take a screenshot/paste the text of the error appearing in the console when executing oshot

### NixOS
On NixOS, TESSDATA_PREFIX will need to be set for oshot to find the languages.
You have two ways to do this, depending on how you installed tesseract.

If you installed tesseract in `environment.systemPackages`, set the following variable:
```nix
environment.sessionVariables = {
# Change tesseract to tesseract5 if that's the package you used.
"TESSDATA_PREFIX" = "${pkgs.tesseract}/share/tessdata";
};
```

If you installed tesseract in `users.users.<user>.packages`, you could use the above method, but it's better you use home-manager.
If you have home-manager, add this in your home.nix:
```nix
systemd.user.sessionVariables = {
# Change tesseract to tesseract5 if that's the package you used.
"TESSDATA_PREFIX" = "${pkgs.tesseract}/share/tessdata";
};
```

> **__Notice:__** If you're not using systemd, the home-manager solution won't work. We assume you'll be able to find a replacement yourself if you're not using systemd.

If this doesn't work, while `echo $TESSDATA_PREFIX` returns a valid result, check your config file.

## Usage
https://github.com/user-attachments/assets/8367490a-f7b0-4320-86e9-8ef8764a56b5
<!--https://github.com/user-attachments/assets/ac505de6-0818-4d67-bb51-064d86f1f970-->
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
description = "Nix flake for oshot; a simple and lightweight tool for extracting text from a screenshot/image (on the fly)";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};

outputs = { self, nixpkgs }: {
packages.x86_64-linux.oshot =
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
name = "oshot";
src = self;
nativeBuildInputs = [ cmake gnumake pkg-config git ];
buildInputs = [ glfw3 leptonica libx11.dev tesseract zbar.dev libappindicator-gtk3.dev dbus.dev systemd.dev libsysprof-capture pcre2.dev libxdmcp.dev libuuid.dev libselinux.dev libsepol.dev libthai.dev libdatrie.dev libdeflate lerc.dev xz.dev zstd.dev libwebp libxkbcommon.dev libepoxy.dev libxtst giflib ];
configurePhase = ''
cmake -DCMAKE_BUILD_PREFIX=/usr -DDEBUG=0 -G "Unix Makefiles" -B build -S .
'';
buildPhase = ''
cmake --build build -j$(nproc)
'';
installPhase = ''
install -Dm755 build/oshot $out/bin/oshot
install -Dm644 oshot.desktop $out/share/applications/oshot.desktop
install -Dm644 LICENSE $out/share/licenses/oshot/LICENSE
'';
};
packages.x86_64-linux.default = self.packages.x86_64-linux.oshot;
};
}
1 change: 1 addition & 0 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ void apply_imgui_theme();
// default config
inline constexpr std::string_view AUTOCONFIG = R"#([default]
# Default Path to where we'll use all the '.traineddata' models.
# The TESSDATA_PREFIX environment variable supersedes this.
ocr-path = "{}"

# Default OCR model.
Expand Down
6 changes: 6 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ void Config::LoadConfigFile(const std::string& filename)

File.allow_out_edit = GetValue<bool>("default.allow-edit-ocr", false); // deprecated
File.allow_out_edit = GetValue<bool>("default.allow-text-edit", File.allow_out_edit);

const char* tessdata_prefix;
if ((tessdata_prefix = getenv("TESSDATA_PREFIX")))
{
File.ocr_path = tessdata_prefix;
}
}

void Config::LoadThemeFile(const std::string& filename)
Expand Down
Loading