Saturday, February 24, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  4] [ 0]  / answers: 1 / hits: 9000  / 1 Year ago, fri, december 2, 2022, 9:36:54

I had hoped that solaar would help, but it seems to only work for the Logitech wireless devices that use Logitech's proprietary scheme. I have Bluetooth keyboard (K760). I know it can be told to use the function keys (rather than the media keys) by default because I can do it on under OS X with software from Logitech. Just remapping the keys won't work as F1, F2, and F3 are special in that they switch which Bluetooth device I connect to and the keys are not sent to the OS.

More From » keyboard


It looks like the changes to the C code from the other answer do work (but off turns on the function keys, I had thought on would do that). I wanted to extend the code to auto-detect the keyboard for me and couldn't bear the thought of writing file searching code in C, so I ported the code to Perl 5:


use strict;
use warnings;

use constant HIDIOCGRAWINFO => 2148026371;
use constant BUS_BLUETOOTH => 5;
use constant HID_VENDOR_ID_LOGITECH => 1133;
use constant HID_DEVICE_ID_K760 => -19690;
use constant HID_DEVICE_ID_K760_ALT => -19688;
use constant HID_DEVICE_ID_K810 => -19687;

my %message = (
HID_DEVICE_ID_K760() => {
on => (pack "C*", 0x10, 0xff, 0x05, 0x14, 0x00, 0x00, 0x00),
off => (pack "C*", 0x10, 0xff, 0x05, 0x14, 0x01, 0x00, 0x00),
on => (pack "C*", 0x10, 0xff, 0x05, 0x14, 0x00, 0x00, 0x00),
off => (pack "C*", 0x10, 0xff, 0x05, 0x14, 0x01, 0x00, 0x00),
HID_DEVICE_ID_K810() => {
on => (pack "C*", 0x10, 0xff, 0x06, 0x15, 0x00, 0x00, 0x00),
off => (pack "C*", 0x10, 0xff, 0x06, 0x15, 0x01, 0x00, 0x00),

# "usage: $0 [on|off]
# " on makes the media keys the default
# " off makes the function keys the default
#unless @ARGV == 1 and my ($choice) = $ARGV[0] =~ /^(on|off)$/;
my ($choice) = @ARGV ? $ARGV[0] =~ /^(on|off)$/ : "off";

my $device;

# find the first device we can set the option on
# TODO: add a parameter to directly specify a device
# TODO: add a parameter to make it set all devices
for my $file (</sys/class/hidraw/hidraw*/device/uevent>) {
open my $fh, "<", $file or do {
warn "could not open $file: $!

while (<$fh>) {
if (/HID_NAME=Logitech K(76|81)0/) {
my ($hid_raw_name) = $file =~ m{(hidraw[^/]+)};
$device = "/dev/$hid_raw_name";

die "sorry, could not find a suported device on your machine
" unless $device;

# re-exec with sudo if we can't open the device
unless (-r $device and -w $device) {
# unless we are already root
exec "sudo", $^X, $0, @ARGV unless $> == 0;

open my $dev, "+<", $device or die "could not open device $device: $!

my $success = ioctl $dev, HIDIOCGRAWINFO, my $struct = "";

die "could not determine if $device is supported
" unless $success;

my ($bus_type, $vendor, $product) = unpack "Lss", $struct;

die "detected device $device is not a Bluetooth device
unless $bus_type == BUS_BLUETOOTH;

die "detected device $device is not a Logitech product
unless $vendor == HID_VENDOR_ID_LOGITECH;

die "detected device $device is not a supported product
unless exists $message{$product};

syswrite $dev, $message{$product}{$choice};

close $dev;

Update: quick and dirty solution to the there being more than one device id for K760.

[#30135] Sunday, December 4, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 390
Total Questions: 106
Total Answers: 115

Location: Tokelau
Member since Sun, May 7, 2023
10 Months ago
nalystcul questions
Sun, May 1, 22, 17:05, 2 Years ago
Mon, Sep 6, 21, 08:12, 3 Years ago
Fri, Mar 18, 22, 20:06, 2 Years ago