oneplus-fajita: Add msm-modem-uim-selection
Restart = "always";
};
};
+ msm-modem-uim-selection = {
+ enable = true;
+ before = [ "ModemManager.service" ];
+ wantedBy = [ "ModemManager.service" ];
+ path = with pkgs; [ libqmi gawk gnugrep ];
+ script = ''
+ QMICLI_MODEM="qmicli --silent -pd qrtr://0"
+ QMI_CARDS=$($QMICLI_MODEM --uim-get-card-status)
+ if ! printf "%s" "$QMI_CARDS" | grep -Fq "Primary GW: session doesn't exist"
+ then
+ $QMICLI_MODEM --uim-change-provisioning-session='activate=no,session-type=primary-gw-provisioning' > /dev/null
+ fi
+ FIRST_PRESENT_SLOT=$(printf "%s" "$QMI_CARDS" | grep "Card state: 'present'" -m1 -B1 | head -n1 | cut -c7-7)
+ FIRST_PRESENT_AID=$(printf "%s" "$QMI_CARDS" | grep "usim (2)" -m1 -A3 | tail -n1 | awk '{print $1}')
+ $QMICLI_MODEM --uim-change-provisioning-session="slot=$FIRST_PRESENT_SLOT,activate=yes,session-type=primary-gw-provisioning,aid=$FIRST_PRESENT_AID" > /dev/null
+ '';
+ serviceConfig = {
+ Type = "oneshot";
+ RemainAfterExit = true;
+ };
+ };
};
